···
16
-
name: "Complete schema with class system",
16
+
name: "Initial schema with all tables and constraints",
CREATE TABLE IF NOT EXISTS users (
···
role TEXT NOT NULL DEFAULT 'user',
27
+
email_verified BOOLEAN DEFAULT 0,
28
+
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);
34
+
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);
90
+
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);
139
-
name: "Add section column to classes table",
141
-
ALTER TABLE classes ADD COLUMN section TEXT;
142
-
CREATE INDEX IF NOT EXISTS idx_classes_course_code ON classes(course_code);
147
-
name: "Add class waitlist table",
139
+
CREATE INDEX IF NOT EXISTS idx_transcriptions_meeting_time_id ON transcriptions(meeting_time_id);
141
+
-- 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,
150
+
meeting_times TEXT,
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);
169
-
name: "Add meeting_times to class_waitlist",
171
-
ALTER TABLE class_waitlist ADD COLUMN meeting_times TEXT;
176
-
name: "Remove section columns",
178
-
DROP INDEX IF EXISTS idx_classes_section;
179
-
ALTER TABLE classes DROP COLUMN section;
180
-
ALTER TABLE class_waitlist DROP COLUMN section;
185
-
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);
209
-
name: "Create ghost user for deleted accounts",
211
-
-- Create a ghost user account for orphaned transcriptions
212
-
INSERT OR IGNORE INTO users (id, email, password_hash, name, avatar, role, created_at)
213
-
VALUES (0, 'ghosty@thistle.internal', NULL, 'Ghosty', '👻', 'user', strftime('%s', 'now'));
218
-
name: "Add email verification system",
220
-
-- Add email verification flag to users
221
-
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);
252
-
name: "Add email notification preferences",
254
-
ALTER TABLE users ADD COLUMN email_notifications_enabled BOOLEAN DEFAULT 1;
259
-
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);
278
-
name: "Add NOT NULL constraints and missing indexes",
280
-
-- Note: SQLite doesn't support ALTER COLUMN to add NOT NULL to existing columns
281
-
-- These tables were created in migration 6 and 8, but the columns should have been NOT NULL
282
-
-- The constraints are enforced at the application level, this migration documents the intent
284
-
-- Add missing indexes for performance
285
-
CREATE INDEX IF NOT EXISTS idx_users_email_verified ON users(email_verified);
286
-
CREATE INDEX IF NOT EXISTS idx_transcriptions_meeting_time_id ON transcriptions(meeting_time_id);
218
+
-- Create ghost user for deleted accounts
219
+
INSERT OR IGNORE INTO users (id, email, password_hash, name, avatar, role, created_at)
220
+
VALUES (0, 'ghosty@thistle.internal', NULL, 'Ghosty', '👻', 'user', strftime('%s', 'now'));