-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename tutor_chats->chats; migrate table w/ new columns.
- Loading branch information
Showing
7 changed files
with
67 additions
and
25 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/codehelp/migrations/20240720--codehelp--improve-chats.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- SPDX-FileCopyrightText: 2024 Mark Liffiton <[email protected]> | ||
-- | ||
-- SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
BEGIN; | ||
|
||
-- Rename tutor_chats -> chats and improve context storage. | ||
|
||
CREATE TABLE chats ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
chat_started TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
topic TEXT NOT NULL, | ||
context_name TEXT, | ||
context_string_id INTEGER, | ||
chat_json TEXT NOT NULL, | ||
user_id INTEGER NOT NULL, | ||
role_id INTEGER, | ||
FOREIGN KEY(user_id) REFERENCES users(id), | ||
FOREIGN KEY(role_id) REFERENCES roles(id), | ||
FOREIGN KEY(context_string_id) REFERENCES context_strings(id) | ||
); | ||
|
||
INSERT INTO chats (id, topic, context_name, chat_json, user_id, role_id) | ||
SELECT | ||
id, | ||
topic, | ||
context, | ||
chat_json, | ||
user_id, | ||
role_id | ||
FROM tutor_chats; | ||
|
||
DROP TABLE tutor_chats; | ||
|
||
DROP INDEX IF EXISTS tutor_chats_by_user; | ||
CREATE INDEX chats_by_user ON chats(user_id); | ||
DROP INDEX IF EXISTS tutor_chats_by_role; | ||
CREATE INDEX chats_by_role ON chats(role_id); | ||
|
||
COMMIT; | ||
|
||
VACUUM; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters