5RSETDN4QCQLU7Z55EFXSW27CBEW6HD2MVD2MKB6WDBXIKXFHKNQC
5XHBBUBSPTNNPEZZVELCS5AEAKQVHEMLAI2URKBMMBUGWTPARFVQC
BPHFBV52V4OA6WLKXGFK7Q4IM5EUS2SKAW5ZGSA6K3NJFJJVATIAC
WA2FN2YR2TDCOLDWCZPYHRHPKJXE7KUB7AFERUCEB3KODVBNCUVQC
E4HFJ4L4PAGV7R7EXVG2B2CWDGGW7XWU4D37VURZ66HZ3ILHCFUAC
ZI2RJOZ2HXBHX7L54BTSDKESY6NG5KBJLVHCNY7K7ZLGIUOIHQUQC
NDMM44EV2XD5RP7J4Q25ZX52LUP7WOMTKO3C2PDXW7IWFEVWUW6QC
NJ233BBUD2WBHKNEWPO5JWQTECTGR5F43NYTSNOZ5J3K22U5C47QC
YUWSM4FCXGL5DRWUGCN26ADHV27THP74V6HFUR4CDUICVPIGX3QAC
VIGS24FLOPPTBLIBZIB2LFMYCDZ3AO4FBXYADAKQMJFNPM4JHAGQC
create unique index unique_store_3 on store (name, region, country) where address is null and address2 is null and city is null and postal_code is null;
create unique index unique_store_6 on store (name, address, city, region, country, postal_code) where address is not null and address2 is null and city is not null and postal_code is not null;
create unique index unique_store_7 on store (name, address, address2, city, region, country, postal_code) where address is not null and address2 is not null and city is not null and postal_code is not null;
create unique index upi_store_3 on store (name, region, country) where address is null and address2 is null and city is null and postal_code is null;
create unique index upi_store_6 on store (name, address, city, region, country, postal_code) where address is not null and address2 is null and city is not null and postal_code is not null;
create unique index upi_store_7 on store (name, address, address2, city, region, country, postal_code) where address is not null and address2 is not null and city is not null and postal_code is not null;
open int4range not null,--number of minutes in a week. possible to use int2range instead but need to be user defined. lazy and edge cases... input should be [,) in case someone puts as end and start for two separate entries, won't collide https://stackoverflow.com/a/27971136
exclude using gist (store_id with =, open with &&) where (not isempty(open))
open int4range not null check (not isempty(open)),--number of minutes in a week. possible to use int2range instead but need to be user defined. lazy and edge cases... input should be [,) in case someone puts as end and start for two separate entries, won't collide https://stackoverflow.com/a/27971136
exclude using gist (store_id with =, open with &&)
create unique index unique_product_3p on product (producer, joined_name, type) where brand is null;
create unique index unique_product_3b on product (brand, joined_name, type) where producer is null;
create unique index unique_product_4 on product (producer, brand, joined_name, type) where brand is not null and producer is not null;
create unique index upi_product_3p on product (producer, joined_name, type) where brand is null;
create unique index upi_product_3b on product (brand, joined_name, type) where producer is null;
create unique index upi_product_4 on product (producer, brand, joined_name, type) where brand is not null and producer is not null;
create unique index unique_variant_2 on variant (product_id, quantity) where portions is null and flavor is null;
create unique index unique_variant_3_portions on variant (product_id, portions, quantity) where portions is not null and flavor is null;
create unique index unique_variant_3_flavor on variant (product_id, quantity, flavor) where portions is null and flavor is not null;
create unique index unique_variant_4 on variant (product_id, portions, quantity, flavor) where portions is not null and flavor is not null;
create unique index upi_variant_2 on variant (product_id, quantity) where portions is null and flavor is null;
create unique index upi_variant_3_portions on variant (product_id, portions, quantity) where portions is not null and flavor is null;
create unique index upi_variant_3_flavor on variant (product_id, quantity, flavor) where portions is null and flavor is not null;
create unique index upi_variant_4 on variant (product_id, portions, quantity, flavor) where portions is not null and flavor is not null;