add sql scripts

This commit is contained in:
amentis 2023-12-05 11:56:25 +02:00
parent bc0d39a72f
commit 5047d3b154
6 changed files with 184 additions and 0 deletions

View File

@ -0,0 +1,18 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.027';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
ALTER TABLE public."Notification"
RENAME TO "NotificationLegacy";
ALTER TABLE public."NotificationLegacy"
RENAME CONSTRAINT "Notification_pkey" TO "NotificationLegacy_pkey";
ALTER TABLE public."NotificationLegacy"
RENAME CONSTRAINT "Notification_UserId_fkey" TO "NotificationLegacy_UserId_fkey";
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.027', '2023-12-05 12:00:00.000000+02', now(), 'Rename table Notification to NotificationLegacy.');
END$$;

View File

@ -0,0 +1,42 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.028';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."Notification"
(
id uuid NOT NULL,
"user" uuid,
tenant uuid,
type uuid,
contact_type_hint character varying(200),
contact_hint character varying(200),
notified_at timestamp without time zone,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
is_active character varying(100) NOT NULL,
data text,
notify_state character varying(200),
notified_with character varying(200),
retry_count integer,
tracking_data text,
provenance_ref character varying(200),
tracking_state smallint NOT NULL,
tracking_process smallint NOT NULL,
CONSTRAINT "Notification_pkey" PRIMARY KEY (id),
CONSTRAINT "Notification_tenant_fkey" FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID,
CONSTRAINT "Notification_user_fkey" FOREIGN KEY ("user")
REFERENCES public."User" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.028', '2023-12-05 12:00:00.000000+02', now(), 'Add table Notification.');
END$$;

View File

@ -0,0 +1,31 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.029';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."QueueOutbox"
(
id uuid NOT NULL,
exchange character varying(200) NOT NULL,
route character varying(200) NOT NULL,
message_id uuid NOT NULL,
notify_status character varying(100) NOT NULL,
retry_count integer NOT NULL,
published_at timestamp without time zone,
confirmed_at timestamp without time zone,
tenant uuid,
is_active timestamp without time zone NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
CONSTRAINT "QueueOutbox_pkey" PRIMARY KEY (id),
CONSTRAINT "QueueOutbox_tennat_fkey" FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.029', '2023-12-05 12:00:00.000000+02', now(), 'Add table QueueOutbox.');
END$$;

View File

@ -0,0 +1,32 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.030';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."QueueInbox"
(
id uuid NOT NULL,
queue character varying(50) NOT NULL,
exchange character varying(50) NOT NULL,
route character varying(50) NOT NULL,
application_id character varying(100) NOT NULL,
message_id uuid NOT NULL,
message json NOT NULL,
retry_count integer,
tennant uuid,
is_active timestamp without time zone NOT NULL,
status character varying(50) NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
CONSTRAINT "QueryInbox_pkey" PRIMARY KEY (id),
CONSTRAINT "QueryInbox_tennant_fkey" FOREIGN KEY (tennant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.030', '2023-12-05 12:00:00.000000+02', now(), 'Add table QueueInbox.');
END$$;

View File

@ -0,0 +1,31 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.031';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."NTFQueueInbox"
(
id uuid NOT NULL,
queue character varying(50) COLLATE pg_catalog."default" NOT NULL,
exchange character varying(50) COLLATE pg_catalog."default" NOT NULL,
route character varying(50) COLLATE pg_catalog."default" NOT NULL,
application_id character varying(100) COLLATE pg_catalog."default" NOT NULL,
message_id uuid NOT NULL,
message json NOT NULL,
retry_count integer,
tennant uuid,
is_active timestamp without time zone NOT NULL,
status character varying(50) COLLATE pg_catalog."default" NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
CONSTRAINT "NTFQueryInbox_pkey" PRIMARY KEY (id),
CONSTRAINT "NTFQueryInbox_tennant_fkey" FOREIGN KEY (tennant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.031', '2023-12-05 12:00:00.000000+02', now(), 'Add table NTFQueueInbox.');
END$$;

View File

@ -0,0 +1,30 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.01.032';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
CREATE TABLE public."NTFQueueOutbox"
(
id uuid NOT NULL,
exchange character varying(200) COLLATE pg_catalog."default" NOT NULL,
route character varying(200) COLLATE pg_catalog."default" NOT NULL,
message_id uuid NOT NULL,
notify_status character varying(100) COLLATE pg_catalog."default" NOT NULL,
retry_count integer NOT NULL,
published_at timestamp without time zone,
confirmed_at timestamp without time zone,
tenant uuid,
is_active timestamp without time zone NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
CONSTRAINT "NTFQueueOutbox_pkey" PRIMARY KEY (id),
CONSTRAINT "NTFQueueOutbox_tennat_fkey" FOREIGN KEY (tenant)
REFERENCES public."Tenant" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.032', '2023-12-05 12:00:00.000000+02', now(), 'Add table NTFQueueOutboox.');
END$$;