electricity_bill_calc_service/migration/20220915131901_add_constraints.up.sql

31 lines
1.4 KiB
SQL

alter table if exists `user` add constraint user_type_check check (type in (0, 1, 2));
alter table if exists user_detail add constraint positive_service_fee check (unit_service_fee >= 0);
alter table if exists user_charge add constraint positive_fee check (fee >= 0);
alter table if exists user_charge add constraint positive_amount check (amount >= 0);
alter table if exists park add constraint positive_tenement check (tenement_quantity >= 0);
alter table if exists park add constraint positive_area check (area >= 0);
alter table if exists park add constraint positive_capacity check (capacity >= 0);
alter table if exists park add constraint category_check check (category in (0, 1, 2));
alter table if exists park add constraint meter_check check (meter_04kv_type in (0, 1));
alter table if exists meter_04kv add constraint positive_ratio check (ratio > 0);
alter table if exists maintenance_fee add constraint positive_fee check (fee >= 0);
alter table if exists report add constraint category_check check (category in (0, 1, 2));
alter table if exists report add constraint meter_check check (meter_04kv_type in (0, 1));
alter table if exists report add constraint withdraw_action_check check (withdraw in (0, 1, 2, 3));
alter table if exists will_diluted_fee add constraint positive_fee check (fee >= 0);
alter table if exists end_user_detail add constraint positive_ratio check (ratio > 0);