setting, session and profile

This commit is contained in:
debu-2 2026-10-07 03:19:09 +05:30
parent 48eea5d201
commit 4a563f4f34
31 changed files with 1797 additions and 159 deletions

View file

@ -151,6 +151,30 @@ async def migrate_user_org_columns(connection) -> None:
"REFERENCES org_sections(id)"
)
)
await connection.execute(
text("ALTER TABLE users ADD COLUMN IF NOT EXISTS profile_picture_url TEXT")
)
await connection.execute(
text(
"ALTER TABLE users ADD COLUMN IF NOT EXISTS mfa_enabled BOOLEAN "
"NOT NULL DEFAULT FALSE"
)
)
await connection.execute(
text(
"ALTER TABLE users ADD COLUMN IF NOT EXISTS session_timeout_minutes "
"INTEGER NOT NULL DEFAULT 10080"
)
)
await connection.execute(
text(
"ALTER TABLE org_security_settings "
"ALTER COLUMN session_timeout_minutes SET DEFAULT 10080"
)
)
await connection.execute(text("ALTER TABLE users DROP CONSTRAINT IF EXISTS users_phone_number_key"))
await connection.execute(text("DROP INDEX IF EXISTS users_phone_number_key"))
await connection.execute(text("DROP INDEX IF EXISTS ix_users_phone_number"))
async def migrate_legacy_user_tables(connection) -> None:
@ -342,6 +366,31 @@ async def lifespan(_: FastAPI):
mongo_db.mailbox_entries,
[("account_id", 1), ("message_scope", 1), ("mailbox", 1), ("event_at", -1)],
)
await ensure_mongo_index(
mongo_db.signup_otps,
[("phone_key", 1), ("consumed", 1), ("created_at", -1)],
)
await ensure_mongo_index(
mongo_db.signup_otps,
[("expires_at", 1)],
expireAfterSeconds=0,
name="signup_otps_expires_at_ttl",
)
await ensure_mongo_index(
mongo_db.signup_otps,
[("phone_key", 1), ("purpose", 1), ("purpose_key", 1), ("consumed", 1), ("created_at", -1)],
)
await ensure_mongo_index(
mongo_db.login_mfa_challenges,
[("challenge_token", 1)],
unique=True,
)
await ensure_mongo_index(
mongo_db.login_mfa_challenges,
[("expires_at", 1)],
expireAfterSeconds=0,
name="login_mfa_challenges_expires_at_ttl",
)
await ensure_mongo_index(
mongo_db.messages,
[("message_id", 1), ("message_scope", 1)],