argos/dmp-db-scema/updates/00.01.044_drop_old_Lock_and...

33 lines
1.1 KiB
MySQL
Raw Normal View History

2023-12-08 17:05:48 +01:00
DO $$DECLARE
2024-02-21 17:37:24 +01:00
this_version CONSTANT varchar := '00.01.044';
2023-12-08 17:05:48 +01:00
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
DROP TABLE public."Lock";
CREATE TABLE public."Lock"
(
id uuid NOT NULL,
target uuid NOT NULL,
target_type smallint NOT NULL,
locked_by uuid NOT NULL,
locked_at timestamp without time zone NOT NULL,
touched_at timestamp without time zone,
tenant uuid,
CONSTRAINT "Lock_pkey" PRIMARY KEY (id),
CONSTRAINT "Lock_lockedby_fkey" FOREIGN KEY (locked_by)
REFERENCES public."User" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "Lock_tenant_fkey" FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
2024-02-21 17:37:24 +01:00
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.044', '2023-12-08 12:00:00.000000+02', now(), 'Drop old Lock Table and create New Lock table.');
2023-12-08 17:05:48 +01:00
END$$;