BEGIN;

CREATE TABLE design (
  design_style text
);

ALTER TABLE design ADD CONSTRAINT "design_style_is_invalid"  
    CHECK (design_style = ANY (ARRAY['rls'::text, 'sdp'::text, 'rf'::text, 'ssa'::text, 'rom'::text, 'rpt'::text, 
                                     'analog'::text, 'sdprpt'::text, 'clkdist'::text, 'global'::text]));

INSERT INTO design (design_style)
    SELECT 'rpt' FROM generate_series(1, 500000);

UPDATE design
  SET design_style = 'rf'
  WHERE design_style = 'rpt';

ROLLBACK;


BEGIN;

CREATE TABLE design_style (
  style_name text PRIMARY KEY
);

INSERT INTO design_style (style_name)
    VALUES ('rls'), ('sdp'), ('rf'), ('ssa'), ('rom'), ('rpt'),
           ('analog'), ('sdprpt'), ('clkdist'), ('global');

CREATE TABLE design (
  design_style text
);

ALTER TABLE design
  ADD CONSTRAINT "design_style_fk"
  FOREIGN KEY ("design_style") REFERENCES "design_style"("style_name");

INSERT INTO design (design_style)
    SELECT 'rpt' FROM generate_series(1, 500000);

UPDATE design
  SET design_style = 'rf'
  WHERE design_style = 'rpt';

ROLLBACK;
