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:
parent
9a98f86077
commit
b9ea6641ff
26
src/migrations/20241016090534-ai-chats.js
Normal file
26
src/migrations/20241016090534-ai-chats.js
Normal 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,
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user