argos/dmp-db-scema/updates/00.01.011_Align_UserDescrip...

29 lines
1.3 KiB
SQL

ALTER TABLE public."UserDatasetProfile" RENAME TO "UserDescriptionTemplate";
ALTER TABLE public."UserDescriptionTemplate" RENAME usr TO "user";
ALTER TABLE public."UserDescriptionTemplate" RENAME "descriptionTemplate" TO description_template;
ALTER TABLE public."UserDescriptionTemplate" ALTER COLUMN "role" TYPE smallint;
ALTER TABLE public."UserDescriptionTemplate" ALTER COLUMN "role" SET NOT NULL;
ALTER TABLE public."UserDescriptionTemplate" ADD COLUMN updated_at timestamp without time zone;
ALTER TABLE public."UserDescriptionTemplate" ADD COLUMN created_at timestamp without time zone;
ALTER TABLE public."UserDescriptionTemplate" ADD COLUMN is_active smallint;
UPDATE public."UserDescriptionTemplate" SET is_active = 1;
UPDATE public."UserDescriptionTemplate" SET is_active = 0 where role = 2;
UPDATE public."UserDescriptionTemplate" SET role = 1 where is_active = 0;
ALTER TABLE public."UserDescriptionTemplate" ALTER COLUMN is_active SET NOT NULL;
UPDATE public."UserDescriptionTemplate" SET updated_at = now() at time zone 'utc';
ALTER TABLE public."UserDescriptionTemplate" ALTER COLUMN updated_at SET NOT NULL;
UPDATE public."UserDescriptionTemplate" SET created_at = now() at time zone 'utc';
ALTER TABLE public."UserDescriptionTemplate" ALTER COLUMN created_at SET NOT NULL;