Update
This commit is contained in:
@@ -38,6 +38,7 @@ def init_db():
|
||||
_index(db, "users", "idx_users_role", ["role", "created_at"])
|
||||
_index(db, "users", "idx_users_last_seen", ["last_seen"])
|
||||
_index(db, "users", "idx_users_created_at", ["created_at"])
|
||||
_ensure_users_uid()
|
||||
_index(db, "posts", "idx_posts_user_uid", ["user_uid"])
|
||||
_index(db, "posts", "idx_posts_created_at", ["created_at"])
|
||||
_index(db, "posts", "idx_posts_topic", ["topic"])
|
||||
@@ -2059,6 +2060,26 @@ def migrate_ai_gateway_settings() -> None:
|
||||
migrate_retired_image_gateway()
|
||||
|
||||
|
||||
def _ensure_users_uid() -> int:
|
||||
if "users" not in db.tables:
|
||||
return 0
|
||||
users = get_table("users")
|
||||
if not users.has_column("uid"):
|
||||
users.create_column_by_example("uid", "")
|
||||
import uuid_utils
|
||||
|
||||
updated = 0
|
||||
for user in users.find():
|
||||
if not user.get("uid"):
|
||||
users.update(
|
||||
{"id": user["id"], "uid": str(uuid_utils.uuid7())}, ["id"]
|
||||
)
|
||||
updated += 1
|
||||
if updated:
|
||||
logger.info("Backfilled uid for %s user(s)", updated)
|
||||
return updated
|
||||
|
||||
|
||||
def backfill_api_keys() -> int:
|
||||
users = get_table("users")
|
||||
if not users.has_column("api_key"):
|
||||
|
||||
Reference in New Issue
Block a user