release: bump version to 0.78.0
This commit is contained in:
1 parent
e6aa8c539b
commit
5fc698d738
96 files changed
+10214
-747
No files matched your search
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Versioned database migration CLI for Planet."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import asyncio
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
BACKEND_DIR = REPO_ROOT / "backend"
|
||||
if str(BACKEND_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(BACKEND_DIR))
|
||||
|
||||
from app.db.migrations import get_migration_status, run_migrations, stamp_migrations # noqa: E402
|
||||
from app.db.session import engine # noqa: E402
|
||||
|
||||
|
||||
async def _run_command(args: argparse.Namespace) -> int:
|
||||
try:
|
||||
if args.command == "status":
|
||||
status = await get_migration_status(engine)
|
||||
print(json.dumps(status, indent=2, ensure_ascii=False))
|
||||
return 1 if status["mismatches"] else 0
|
||||
if args.command == "upgrade":
|
||||
applied = await run_migrations(engine)
|
||||
print(json.dumps({"applied": applied}, ensure_ascii=False))
|
||||
return 0
|
||||
if args.command == "stamp":
|
||||
stamped = await stamp_migrations(engine, args.version)
|
||||
print(json.dumps({"stamped": stamped}, ensure_ascii=False))
|
||||
return 0
|
||||
return 2
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Planet versioned schema migration helper")
|
||||
subparsers = parser.add_subparsers(dest="command", required=True)
|
||||
subparsers.add_parser("status", help="Show applied, pending, and checksum-mismatched migrations")
|
||||
subparsers.add_parser("upgrade", help="Apply all pending migrations")
|
||||
stamp_parser = subparsers.add_parser("stamp", help="Mark migrations up to VERSION as applied")
|
||||
stamp_parser.add_argument("version", help="4-digit migration version (e.g. 0001)")
|
||||
args = parser.parse_args()
|
||||
return asyncio.run(_run_command(args))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user