diff --git a/bun.lockb b/bun.lockb index 13f7117668..cb32c781b3 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/packages/postgres/migrations/01_message.sql b/packages/postgres/migrations/01_message.sql new file mode 100644 index 0000000000..8aa19866f9 --- /dev/null +++ b/packages/postgres/migrations/01_message.sql @@ -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) +); diff --git a/packages/postgres/migrations/02_attachment.sql b/packages/postgres/migrations/02_attachment.sql new file mode 100644 index 0000000000..b74d0ec0ed --- /dev/null +++ b/packages/postgres/migrations/02_attachment.sql @@ -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); diff --git a/packages/postgres/migrations/03_reaction.sql b/packages/postgres/migrations/03_reaction.sql new file mode 100644 index 0000000000..5dc21091f7 --- /dev/null +++ b/packages/postgres/migrations/03_reaction.sql @@ -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); diff --git a/packages/postgres/migrations/04_notification.sql b/packages/postgres/migrations/04_notification.sql new file mode 100644 index 0000000000..96b53f1a6d --- /dev/null +++ b/packages/postgres/migrations/04_notification.sql @@ -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) +); diff --git a/packages/postgres/migrations/05_notificationContext.sql b/packages/postgres/migrations/05_notificationContext.sql new file mode 100644 index 0000000000..f8936f24cc --- /dev/null +++ b/packages/postgres/migrations/05_notificationContext.sql @@ -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) +); diff --git a/packages/postgres/package.json b/packages/postgres/package.json new file mode 100644 index 0000000000..3a7faecac7 --- /dev/null +++ b/packages/postgres/package.json @@ -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" + } +} diff --git a/packages/postgres/src/index.ts b/packages/postgres/src/index.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/postgres/tsconfig.json b/packages/postgres/tsconfig.json new file mode 100644 index 0000000000..49e05cea1e --- /dev/null +++ b/packages/postgres/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src"] +}