···
-
name: "Complete schema with class system",
CREATE TABLE IF NOT EXISTS users (
···
role TEXT NOT NULL DEFAULT 'user',
created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
CREATE INDEX IF NOT EXISTS idx_users_role ON users(role);
CREATE INDEX IF NOT EXISTS idx_users_last_login ON users(last_login);
CREATE TABLE IF NOT EXISTS sessions (
···
CREATE INDEX IF NOT EXISTS idx_classes_semester_year ON classes(semester, year);
CREATE INDEX IF NOT EXISTS idx_classes_archived ON classes(archived);
CREATE TABLE IF NOT EXISTS class_members (
···
CREATE INDEX IF NOT EXISTS idx_transcriptions_class_id ON transcriptions(class_id);
CREATE INDEX IF NOT EXISTS idx_transcriptions_status ON transcriptions(status);
CREATE INDEX IF NOT EXISTS idx_transcriptions_whisper_job_id ON transcriptions(whisper_job_id);
-
name: "Add section column to classes table",
-
ALTER TABLE classes ADD COLUMN section TEXT;
-
CREATE INDEX IF NOT EXISTS idx_classes_course_code ON classes(course_code);
-
name: "Add class waitlist table",
CREATE TABLE IF NOT EXISTS class_waitlist (
user_id INTEGER NOT NULL,
course_code TEXT NOT NULL,
course_name TEXT NOT NULL,
created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now')),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
···
CREATE INDEX IF NOT EXISTS idx_waitlist_user_id ON class_waitlist(user_id);
CREATE INDEX IF NOT EXISTS idx_waitlist_course_code ON class_waitlist(course_code);
-
name: "Add meeting_times to class_waitlist",
-
ALTER TABLE class_waitlist ADD COLUMN meeting_times TEXT;
-
name: "Remove section columns",
-
DROP INDEX IF EXISTS idx_classes_section;
-
ALTER TABLE classes DROP COLUMN section;
-
ALTER TABLE class_waitlist DROP COLUMN section;
-
name: "Add subscriptions table for Polar integration",
CREATE TABLE IF NOT EXISTS subscriptions (
···
CREATE INDEX IF NOT EXISTS idx_subscriptions_user_id ON subscriptions(user_id);
CREATE INDEX IF NOT EXISTS idx_subscriptions_status ON subscriptions(status);
CREATE INDEX IF NOT EXISTS idx_subscriptions_customer_id ON subscriptions(customer_id);
-
name: "Create ghost user for deleted accounts",
-
-- Create a ghost user account for orphaned transcriptions
-
INSERT OR IGNORE INTO users (id, email, password_hash, name, avatar, role, created_at)
-
VALUES (0, 'ghosty@thistle.internal', NULL, 'Ghosty', '👻', 'user', strftime('%s', 'now'));
-
name: "Add email verification system",
-
-- Add email verification flag to users
-
ALTER TABLE users ADD COLUMN email_verified BOOLEAN DEFAULT 0;
-- Email verification tokens table
CREATE TABLE IF NOT EXISTS email_verification_tokens (
···
CREATE INDEX IF NOT EXISTS idx_password_reset_tokens_user_id ON password_reset_tokens(user_id);
CREATE INDEX IF NOT EXISTS idx_password_reset_tokens_token ON password_reset_tokens(token);
-
name: "Add email notification preferences",
-
ALTER TABLE users ADD COLUMN email_notifications_enabled BOOLEAN DEFAULT 1;
-
name: "Add email change tokens table",
-- Email change tokens table
CREATE TABLE IF NOT EXISTS email_change_tokens (
···
CREATE INDEX IF NOT EXISTS idx_email_change_tokens_user_id ON email_change_tokens(user_id);
CREATE INDEX IF NOT EXISTS idx_email_change_tokens_token ON email_change_tokens(token);
-
name: "Add NOT NULL constraints and missing indexes",
-
-- Note: SQLite doesn't support ALTER COLUMN to add NOT NULL to existing columns
-
-- These tables were created in migration 6 and 8, but the columns should have been NOT NULL
-
-- The constraints are enforced at the application level, this migration documents the intent
-
-- Add missing indexes for performance
-
CREATE INDEX IF NOT EXISTS idx_users_email_verified ON users(email_verified);
-
CREATE INDEX IF NOT EXISTS idx_transcriptions_meeting_time_id ON transcriptions(meeting_time_id);
···
+
name: "Initial schema with all tables and constraints",
CREATE TABLE IF NOT EXISTS users (
···
role TEXT NOT NULL DEFAULT 'user',
+
email_verified BOOLEAN DEFAULT 0,
+
email_notifications_enabled BOOLEAN DEFAULT 1,
created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
CREATE INDEX IF NOT EXISTS idx_users_role ON users(role);
CREATE INDEX IF NOT EXISTS idx_users_last_login ON users(last_login);
+
CREATE INDEX IF NOT EXISTS idx_users_email_verified ON users(email_verified);
CREATE TABLE IF NOT EXISTS sessions (
···
CREATE INDEX IF NOT EXISTS idx_classes_semester_year ON classes(semester, year);
CREATE INDEX IF NOT EXISTS idx_classes_archived ON classes(archived);
+
CREATE INDEX IF NOT EXISTS idx_classes_course_code ON classes(course_code);
CREATE TABLE IF NOT EXISTS class_members (
···
CREATE INDEX IF NOT EXISTS idx_transcriptions_class_id ON transcriptions(class_id);
CREATE INDEX IF NOT EXISTS idx_transcriptions_status ON transcriptions(status);
CREATE INDEX IF NOT EXISTS idx_transcriptions_whisper_job_id ON transcriptions(whisper_job_id);
+
CREATE INDEX IF NOT EXISTS idx_transcriptions_meeting_time_id ON transcriptions(meeting_time_id);
+
-- Class waitlist table
CREATE TABLE IF NOT EXISTS class_waitlist (
user_id INTEGER NOT NULL,
course_code TEXT NOT NULL,
course_name TEXT NOT NULL,
created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now')),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
···
CREATE INDEX IF NOT EXISTS idx_waitlist_user_id ON class_waitlist(user_id);
CREATE INDEX IF NOT EXISTS idx_waitlist_course_code ON class_waitlist(course_code);
CREATE TABLE IF NOT EXISTS subscriptions (
···
CREATE INDEX IF NOT EXISTS idx_subscriptions_user_id ON subscriptions(user_id);
CREATE INDEX IF NOT EXISTS idx_subscriptions_status ON subscriptions(status);
CREATE INDEX IF NOT EXISTS idx_subscriptions_customer_id ON subscriptions(customer_id);
-- Email verification tokens table
CREATE TABLE IF NOT EXISTS email_verification_tokens (
···
CREATE INDEX IF NOT EXISTS idx_password_reset_tokens_user_id ON password_reset_tokens(user_id);
CREATE INDEX IF NOT EXISTS idx_password_reset_tokens_token ON password_reset_tokens(token);
-- Email change tokens table
CREATE TABLE IF NOT EXISTS email_change_tokens (
···
CREATE INDEX IF NOT EXISTS idx_email_change_tokens_user_id ON email_change_tokens(user_id);
CREATE INDEX IF NOT EXISTS idx_email_change_tokens_token ON email_change_tokens(token);
+
-- Create ghost user for deleted accounts
+
INSERT OR IGNORE INTO users (id, email, password_hash, name, avatar, role, created_at)
+
VALUES (0, 'ghosty@thistle.internal', NULL, 'Ghosty', '👻', 'user', strftime('%s', 'now'));