Fix blueprints

This commit is contained in:
Joey Yakimowich-Payne 2026-01-16 09:10:19 -07:00
commit 1bfe7e3437
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
4 changed files with 79 additions and 16 deletions

View file

@ -112,7 +112,7 @@ const runMigrations = () => {
const quizTableInfo = db.prepare("PRAGMA table_info(quizzes)").all() as { name: string }[];
const hasShareToken = quizTableInfo.some(col => col.name === "share_token");
if (!hasShareToken) {
db.exec("ALTER TABLE quizzes ADD COLUMN share_token TEXT UNIQUE");
db.exec("ALTER TABLE quizzes ADD COLUMN share_token TEXT");
console.log("Migration: Added share_token to quizzes");
}
@ -124,8 +124,8 @@ const runMigrations = () => {
const shareTokenIndex = db.prepare("SELECT name FROM sqlite_master WHERE type='index' AND name='idx_quizzes_share_token'").get();
if (!shareTokenIndex) {
db.exec("CREATE INDEX idx_quizzes_share_token ON quizzes(share_token)");
console.log("Migration: Created index on quizzes.share_token");
db.exec("CREATE UNIQUE INDEX idx_quizzes_share_token ON quizzes(share_token)");
console.log("Migration: Created unique index on quizzes.share_token");
}
};

View file

@ -60,7 +60,5 @@ CREATE TABLE IF NOT EXISTS game_sessions (
);
CREATE INDEX IF NOT EXISTS idx_quizzes_user ON quizzes(user_id);
CREATE INDEX IF NOT EXISTS idx_quizzes_share_token ON quizzes(share_token);
CREATE INDEX IF NOT EXISTS idx_questions_quiz ON questions(quiz_id);
CREATE INDEX IF NOT EXISTS idx_options_question ON answer_options(question_id);
CREATE INDEX IF NOT EXISTS idx_game_sessions_updated ON game_sessions(updated_at);