Skip to content

Commit eef74f0

Browse files
committed
chore: cherry-pick migration 000319_chat (#17570)
Only the migration is pulled, no business logic Co-authored-by: Steven Masley
1 parent 4a70bdc commit eef74f0

File tree

7 files changed

+87
-0
lines changed

7 files changed

+87
-0
lines changed

coderd/database/dump.sql

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/foreign_key_constraint.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DROP TABLE IF EXISTS chat_messages;
2+
3+
DROP TABLE IF EXISTS chats;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CREATE TABLE IF NOT EXISTS chats (
2+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
3+
owner_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
4+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
5+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
6+
title TEXT NOT NULL
7+
);
8+
9+
CREATE TABLE IF NOT EXISTS chat_messages (
10+
-- BIGSERIAL is auto-incrementing so we know the exact order of messages.
11+
id BIGSERIAL PRIMARY KEY,
12+
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
13+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
14+
model TEXT NOT NULL,
15+
provider TEXT NOT NULL,
16+
content JSONB NOT NULL
17+
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
INSERT INTO chats (id, owner_id, created_at, updated_at, title) VALUES
2+
('00000000-0000-0000-0000-000000000001', '0ed9befc-4911-4ccf-a8e2-559bf72daa94', '2023-10-01 12:00:00+00', '2023-10-01 12:00:00+00', 'Test Chat 1');
3+
4+
INSERT INTO chat_messages (id, chat_id, created_at, model, provider, content) VALUES
5+
(1, '00000000-0000-0000-0000-000000000001', '2023-10-01 12:00:00+00', 'annie-oakley', 'cowboy-coder', '{"role":"user","content":"Hello"}'),
6+
(2, '00000000-0000-0000-0000-000000000001', '2023-10-01 12:01:00+00', 'annie-oakley', 'cowboy-coder', '{"role":"assistant","content":"Howdy pardner! What can I do ya for?"}');

coderd/database/models.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/unique_constraint.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy