--conversion script

-- Extra unique key on key columns product/size and customer
-- Create/Recreate primary, unique and foreign key constraints 
alter table PRODUCT
  add constraint PROD_PRODUCTCODE unique (CODE);

-- Create/Recreate primary, unique and foreign key constraints 
alter table SIZEDEFINITION
  add constraint SIZE_UNIQUEKEY_SIZECODE unique (CODE);

-- Create/Recreate primary, unique and foreign key constraints 
alter table CUSTOMER
  add constraint CUST_KEY_CUSTOMERNUMBER unique (CUSTOMERNUMBER);
  
-- Create/Recreate check constraints 
-- If below update fails, delete all records from I_EMBLEMTEMPLATE for they are not good.
update i_emblemtemplate i
   set i.productcode = upper(trim(productcode)),
       i.sizecode = upper(trim(sizecode));

alter table I_EMBLEMTEMPLATE
  add constraint CHK_I_EMBLEMTEMP_PRODUCTCODE
  check (PRODUCTCODE = UPPER(TRIM(PRODUCTCODE)));
alter table I_EMBLEMTEMPLATE
  add constraint CHK_I_EMBLEMTEMP_SIZECODE
  check (SIZECODE = UPPER(TRIM(SIZECODE)));