25 lines
896 B
SQL
25 lines
896 B
SQL
DO $$DECLARE
|
|
this_version CONSTANT varchar := '00.01.013';
|
|
BEGIN
|
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
|
IF FOUND THEN RETURN; END IF;
|
|
|
|
CREATE TABLE IF NOT EXISTS public."DmpUser"
|
|
(
|
|
"id" uuid NOT NULL,
|
|
"dmp" uuid NOT NULL,
|
|
"user" uuid NOT NULL,
|
|
"role" smallint NOT NULL DEFAULT 0,
|
|
"created_at" timestamp without time zone NOT NULL DEFAULT now(),
|
|
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
|
"is_active" smallint NOT NULL DEFAULT 1,
|
|
CONSTRAINT "DmpUser_pkey" PRIMARY KEY (id),
|
|
CONSTRAINT "DmpUser_dmp_fkey" FOREIGN KEY ("dmp")
|
|
REFERENCES public."Dmp" (id),
|
|
CONSTRAINT "DmpUser_user_fkey" FOREIGN KEY ("user")
|
|
REFERENCES public."UserInfo" (id)
|
|
)
|
|
|
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.013', '2023-11-07 12:00:00.000000+02', now(), 'Add Dmp User table (former UserDMP).');
|
|
|
|
END$$; |