Support both email and phone login
Auto-detect whether the user entered an email or phone number. Email sends via Resend, phone sends via Twilio SMS. Users table has nullable phone and email columns; verification_codes uses a generic identifier field. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-2
@@ -10,8 +10,11 @@ func runMigrations(database *sql.DB) {
|
||||
migrations := []string{
|
||||
`ALTER TABLE events ADD COLUMN description TEXT DEFAULT ''`,
|
||||
`ALTER TABLE events ADD COLUMN user_id INTEGER REFERENCES users(id)`,
|
||||
`ALTER TABLE users RENAME COLUMN email TO phone`,
|
||||
`ALTER TABLE verification_codes RENAME COLUMN email TO phone`,
|
||||
// Users may have email, phone, or both. Add whichever column is missing.
|
||||
`ALTER TABLE users ADD COLUMN phone TEXT UNIQUE`,
|
||||
`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 ''`,
|
||||
}
|
||||
for _, m := range migrations {
|
||||
_, err := database.Exec(m)
|
||||
|
||||
Reference in New Issue
Block a user