Merge pull request #230 from openreplay/dev

feat(db): fixed init_schema.sql
This commit is contained in:
Mehdi Osman 2021-12-04 00:29:35 +01:00 committed by GitHub
commit 5f7ab496a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 26 deletions

View file

@ -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;

View file

@ -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