feat(DB): sessions_notes structure
This commit is contained in:
parent
968d25e29e
commit
21632f8c46
4 changed files with 60 additions and 1 deletions
|
|
@ -7,4 +7,19 @@ $$ LANGUAGE sql IMMUTABLE;
|
|||
|
||||
ALTER TABLE IF EXISTS public.tenants
|
||||
ADD COLUMN IF NOT EXISTS last_telemetry bigint NOT NULL DEFAULT CAST(EXTRACT(epoch FROM date_trunc('day', now())) * 1000 AS BIGINT);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions_notes
|
||||
(
|
||||
note_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
message text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
tags text[] NOT NULL DEFAULT '{}',
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
timestamp integer NOT NULL DEFAULT -1,
|
||||
is_public boolean NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -129,7 +129,8 @@ $$
|
|||
('user_viewed_errors'),
|
||||
('user_viewed_sessions'),
|
||||
('users'),
|
||||
('webhooks'))
|
||||
('webhooks'),
|
||||
('sessions_notes'))
|
||||
select bool_and(exists(select *
|
||||
from information_schema.tables t
|
||||
where table_schema = 'public'
|
||||
|
|
@ -857,6 +858,20 @@ $$
|
|||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_alert();
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions_notes
|
||||
(
|
||||
note_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
message text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
tags text[] NOT NULL DEFAULT '{}',
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
timestamp integer NOT NULL DEFAULT -1,
|
||||
is_public boolean NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
RAISE NOTICE 'Created missing public schema tables';
|
||||
END IF;
|
||||
END;
|
||||
|
|
|
|||
|
|
@ -7,4 +7,19 @@ $$ LANGUAGE sql IMMUTABLE;
|
|||
|
||||
ALTER TABLE IF EXISTS public.tenants
|
||||
ADD COLUMN IF NOT EXISTS last_telemetry bigint NOT NULL DEFAULT CAST(EXTRACT(epoch FROM date_trunc('day', now())) * 1000 AS BIGINT);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions_notes
|
||||
(
|
||||
note_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
message text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
tags text[] NOT NULL DEFAULT '{}',
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
timestamp integer NOT NULL DEFAULT -1,
|
||||
is_public boolean NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1000,6 +1000,20 @@ $$
|
|||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_alert();
|
||||
|
||||
CREATE TABLE sessions_notes
|
||||
(
|
||||
note_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
message text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
tags text[] NOT NULL DEFAULT '{}',
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
timestamp integer NOT NULL DEFAULT -1,
|
||||
is_public boolean NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
raise notice 'DB created';
|
||||
END IF;
|
||||
END;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue