chore: sync code and project files
This commit is contained in:
30
scripts/migrate_users_and_owner.py
Normal file
30
scripts/migrate_users_and_owner.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""
|
||||
One-off migration:
|
||||
- Ensure admin exists
|
||||
- Backfill projects.owner_user_id to admin for legacy projects
|
||||
|
||||
Usage:
|
||||
python3 scripts/migrate_users_and_owner.py
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Ensure repo root is on sys.path when executed from scripts/ directory
|
||||
REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
if REPO_ROOT not in sys.path:
|
||||
sys.path.insert(0, REPO_ROOT)
|
||||
|
||||
from modules.db_manager import db
|
||||
|
||||
|
||||
def main():
|
||||
admin_id = db.ensure_admin_user("admin", "admin1234")
|
||||
n = db.migrate_projects_owner_to(admin_id)
|
||||
print(f"admin_id={admin_id} backfilled_projects={n}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user