From 15863c9b2fc0684945ec04d85bcf79717fab293c Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Sat, 4 Dec 2021 00:26:52 +0100 Subject: [PATCH] feat(db): fixed init_schema.sql --- .../db/init_dbs/postgresql/init_schema.sql | 31 +++++++++---------- .../db/init_dbs/postgresql/init_schema.sql | 9 ------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 10448c495..bfd7177ce 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -128,6 +128,19 @@ $$ t_integrations integer NOT NULL DEFAULT 0 ); + + CREATE TABLE roles + ( + role_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, + tenant_id integer NOT NULL REFERENCES tenants (tenant_id) ON DELETE CASCADE, + name text NOT NULL, + description text DEFAULT NULL, + permissions text[] NOT NULL DEFAULT '{}', + protected bool NOT NULL DEFAULT FALSE, + created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()), + deleted_at timestamp NULL DEFAULT NULL + ); + CREATE TYPE user_role AS ENUM ('owner', 'admin', 'member'); CREATE TABLE users @@ -267,7 +280,6 @@ $$ ); CREATE INDEX ON public.projects (project_key); - CREATE INDEX projects_tenant_id_idx ON projects (tenant_id); -- --- alerts.sql --- @@ -319,8 +331,6 @@ $$ name varchar(100) ); -CREATE INDEX webhooks_tenant_id_idx ON webhooks (tenant_id); - -- --- notifications.sql --- @@ -893,23 +903,10 @@ CREATE INDEX webhooks_tenant_id_idx ON webhooks (tenant_id); CREATE INDEX ON jobs (start_at); - CREATE TABLE roles - ( - role_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - tenant_id integer NOT NULL REFERENCES tenants (tenant_id) ON DELETE CASCADE, - name text NOT NULL, - description text DEFAULT NULL, - permissions text[] NOT NULL DEFAULT '{}', - protected bool NOT NULL DEFAULT FALSE, - created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()), - deleted_at timestamp NULL DEFAULT NULL - ); - - raise notice 'DB created'; END IF; END; $$ LANGUAGE plpgsql; -COMMIT; +COMMIT; \ No newline at end of file diff --git a/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 5bdb3f1c7..8458199cb 100644 --- a/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -255,15 +255,6 @@ $$ "defaultInputMode": "plain" }'::jsonb -- ?????? ); - CREATE INDEX ON public.projects (project_key); - - CREATE OR REPLACE FUNCTION notify_project() RETURNS trigger AS - $$ - BEGIN - PERFORM pg_notify('project', row_to_json(NEW)::text); - RETURN NEW; - END; - $$ LANGUAGE plpgsql; CREATE TRIGGER on_insert_or_update AFTER INSERT OR UPDATE