2023-12-06 13:23:21 +01:00
|
|
|
DO $$DECLARE
|
2024-02-21 17:37:24 +01:00
|
|
|
this_version CONSTANT varchar := '00.01.041';
|
2023-12-06 13:23:21 +01:00
|
|
|
BEGIN
|
|
|
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
|
|
|
IF FOUND THEN RETURN; END IF;
|
|
|
|
|
|
|
|
CREATE TABLE public."TenantUser"
|
|
|
|
(
|
|
|
|
id uuid NOT NULL,
|
|
|
|
"user" uuid NOT NULL,
|
|
|
|
tenant uuid NOT NULL,
|
|
|
|
is_active smallint NOT NULL,
|
|
|
|
created_at timestamp without time zone NOT NULL,
|
|
|
|
updated_at timestamp without time zone NOT NULL,
|
|
|
|
CONSTRAINT "TenantUser_pkey" PRIMARY KEY (id),
|
|
|
|
CONSTRAINT "TenantUser_tenant_fkey" FOREIGN KEY (tenant)
|
|
|
|
REFERENCES public."Tenant" (id) MATCH SIMPLE
|
|
|
|
ON UPDATE NO ACTION
|
|
|
|
ON DELETE NO ACTION
|
|
|
|
NOT VALID,
|
|
|
|
CONSTRAINT "TenantUser_user_fkey" FOREIGN KEY ("user")
|
|
|
|
REFERENCES public."User" (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.041', '2023-12-06 12:00:00.000000+02', now(), 'Add table TenantUser.');
|
2023-12-06 13:23:21 +01:00
|
|
|
|
|
|
|
END$$;
|