-- Email is restored to NOT NULL, so phone-only accounts (email IS NULL) cannot -- be represented and are dropped. Down is only safe when no such accounts exist. DELETE FROM users WHERE email IS NULL; CREATE TABLE users_old ( id TEXT PRIMARY KEY, email TEXT NOT NULL UNIQUE, password_hash TEXT NOT NULL, name TEXT NOT NULL, avatar_url TEXT, preferences TEXT NOT NULL DEFAULT '{}', created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) ); INSERT INTO users_old (id, email, password_hash, name, avatar_url, preferences, created_at) SELECT id, email, password_hash, name, avatar_url, preferences, created_at FROM users WHERE email IS NOT NULL; DROP TABLE users; ALTER TABLE users_old RENAME TO users;