argos/dmp-db-scema/updates/00.01.010_Align_Description...

51 lines
1.8 KiB
MySQL
Raw Normal View History

2023-10-27 17:46:34 +02:00
ALTER TABLE public."DescriptionTemplate" RENAME "ID" TO id;
ALTER TABLE public."DescriptionTemplate" RENAME "Label" TO label;
ALTER TABLE public."DescriptionTemplate" RENAME "Definition" TO definition;
ALTER TABLE public."DescriptionTemplate" RENAME "Status" TO status;
ALTER TABLE public."DescriptionTemplate" RENAME "Created" TO created_at;
ALTER TABLE public."DescriptionTemplate" RENAME "Modified" TO updated_at;
ALTER TABLE public."DescriptionTemplate" RENAME "Description" TO description;
ALTER TABLE public."DescriptionTemplate" RENAME "GroupId" TO group_id;
ALTER TABLE public."DescriptionTemplate" RENAME "Version" TO version;
ALTER TABLE public."DescriptionTemplate" RENAME "Language" TO "language";
ALTER TABLE public."DescriptionTemplate" RENAME "Type" TO "type";
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN created_at TYPE timestamp without time zone ;
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN updated_at TYPE timestamp without time zone ;
2023-11-22 12:31:00 +01:00
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN group_id DROP DEFAULT;
2023-10-27 17:46:34 +02:00
ALTER TABLE public."DescriptionTemplate" ADD COLUMN is_active smallint;
UPDATE public."DescriptionTemplate" SET is_active = 1;
UPDATE public."DescriptionTemplate" SET is_active = 0 where status = 99;
UPDATE public."DescriptionTemplate" SET status = 0 where is_active = 0;
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN is_active SET NOT NULL;
ALTER TABLE public."DescriptionTemplate" ADD COLUMN version_status smallint;
UPDATE public."DescriptionTemplate" SET version_status = 1;
UPDATE public."DescriptionTemplate" SET version_status = 0 where id in (
select dt.id from public."DescriptionTemplate" as dt
where dt.version =
(
select Max(f.version)
from public."DescriptionTemplate" as f where f.group_id=dt.group_id
)
);
ALTER TABLE public."DescriptionTemplate" ALTER COLUMN version_status SET NOT NULL;