Merge pull request #2 from hcengineering/init-tables

Init tables
This commit is contained in:
Kristina
2024-12-23 16:20:58 +04:00
committed by GitHub
9 changed files with 85 additions and 0 deletions
BIN
View File
Binary file not shown.
@@ -0,0 +1,19 @@
CREATE TABLE IF NOT EXISTS message
(
id INT8 NOT NULL DEFAULT unique_rowid(),
content TEXT,
version INTEGER NOT NULL,
creator VARCHAR(255) NOT NULL,
created TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (id, version)
);
CREATE TABLE IF NOT EXISTS message_place
(
workspace_id UUID NOT NULL,
card_id UUID NOT NULL,
message_id INT8 NOT NULL,
PRIMARY KEY (workspace_id, card_id, message_id)
);
@@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS attachment
(
message_id INT8 NOT NULL,
card_id UUID NOT NULL,
creator VARCHAR(255) NOT NULL,
created TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (message_id, card_id)
);
CREATE INDEX IF NOT EXISTS attachment_message_idx ON attachment (message_id);
@@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS reaction
(
message_id INT8 NOT NULL,
reaction INTEGER NOT NULL,
creator VARCHAR(255) NOT NULL,
created TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (message_id, creator, reaction)
);
CREATE INDEX IF NOT EXISTS reaction_message_idx ON reaction (message_id);
@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS notification
(
social_id VARCHAR(255) NOT NULL,
message_id INT8 NOT NULL,
PRIMARY KEY (social_id, message_id)
);
@@ -0,0 +1,12 @@
CREATE TABLE IF NOT EXISTS notification_context
(
workspace_id UUID NOT NULL,
card_id UUID NOT NULL,
huly_id VARCHAR(255) NOT NULL, /* Or maybe account id or something else */
archived_from TIMESTAMPTZ,
last_view TIMESTAMPTZ,
last_update TIMESTAMPTZ,
PRIMARY KEY (workspace_id, card_id, huly_id)
);
+17
View File
@@ -0,0 +1,17 @@
{
"name": "@communication/postgres",
"version": "0.1.0",
"module": "src/index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "^1.1.13"
},
"dependencies": {
"@communication/types": "workspace:*",
"pg": "8.12.0",
"postgres": "^3.4.4"
},
"peerDependencies": {
"typescript": "^5.6.3"
}
}
View File
+8
View File
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src"]
}