1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

chore: AI chats db migration (#8460)

https://linear.app/unleash/issue/2-2845/db-migration-ai-chats

Adds a new DB migration for creating a new `ai_chats` table, used on the
Unleash AI experiment.
This commit is contained in:
Nuno Góis 2024-10-16 10:43:52 +01:00 committed by GitHub
parent 9a98f86077
commit b9ea6641ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,26 @@
exports.up = function (db, cb) {
db.runSql(
`
CREATE TABLE IF NOT EXISTS ai_chats
(
id BIGSERIAL PRIMARY KEY NOT NULL,
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
chat JSONB NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_ai_chats_user_id ON ai_chats(user_id);
`,
cb,
);
};
exports.down = function (db, cb) {
db.runSql(
`
DROP INDEX IF EXISTS idx_ai_chats_user_id;
DROP TABLE IF EXISTS ai_chats;
`,
cb,
);
};