diff --git a/migrate.go b/migrate.go index 547dc58..e14af61 100644 --- a/migrate.go +++ b/migrate.go @@ -15,6 +15,9 @@ func runMigrations(database *sql.DB) { `ALTER TABLE users ADD COLUMN email TEXT UNIQUE`, // Verification codes use a generic identifier column. `ALTER TABLE verification_codes ADD COLUMN identifier TEXT NOT NULL DEFAULT ''`, + // Indexes for auth tables (created here so they run after column migrations). + `CREATE INDEX IF NOT EXISTS idx_sessions_user ON sessions(user_id)`, + `CREATE INDEX IF NOT EXISTS idx_verification_codes_identifier ON verification_codes(identifier)`, } for _, m := range migrations { _, err := database.Exec(m) diff --git a/schema.sql b/schema.sql index 6f37680..f77ce16 100644 --- a/schema.sql +++ b/schema.sql @@ -61,5 +61,3 @@ CREATE TABLE IF NOT EXISTS verification_codes ( CREATE INDEX IF NOT EXISTS idx_slots_event ON slots(event_id); CREATE INDEX IF NOT EXISTS idx_claims_slot ON claims(slot_id); CREATE INDEX IF NOT EXISTS idx_rsvps_event ON rsvps(event_id); -CREATE INDEX IF NOT EXISTS idx_sessions_user ON sessions(user_id); -CREATE INDEX IF NOT EXISTS idx_verification_codes_identifier ON verification_codes(identifier);