- Notifications
You must be signed in to change notification settings - Fork1k
chore: cherry-pick migration 000319_chat (#17570)#17869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DROP TABLE IF EXISTS chat_messages; | ||
DROP TABLE IF EXISTS chats; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE TABLE IF NOT EXISTS chats ( | ||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
owner_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
title TEXT NOT NULL | ||
); | ||
CREATE TABLE IF NOT EXISTS chat_messages ( | ||
-- BIGSERIAL is auto-incrementing so we know the exact order of messages. | ||
id BIGSERIAL PRIMARY KEY, | ||
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE, | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
model TEXT NOT NULL, | ||
provider TEXT NOT NULL, | ||
content JSONB NOT NULL | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
INSERT INTO chats (id, owner_id, created_at, updated_at, title) VALUES | ||
('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'); | ||
INSERT INTO chat_messages (id, chat_id, created_at, model, provider, content) VALUES | ||
(1, '00000000-0000-0000-0000-000000000001', '2023-10-01 12:00:00+00', 'annie-oakley', 'cowboy-coder', '{"role":"user","content":"Hello"}'), | ||
(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?"}'); |
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.