mirror of
https://github.com/Cccc-owo/CheckInApp.git
synced 2026-06-17 05:56:29 +00:00
feat(backend): add automatic DB migrations
Add a lightweight migration runner with schema_migrations tracking, run pending migrations during backend startup before the scheduler, and keep a manual backend-migrate entrypoint. The change also moves the existing lockout and task-thread-ID schema steps into shared migration modules, updates docs, and archives the OpenSpec change.
This commit is contained in:
@@ -112,6 +112,13 @@ def run_backend(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def run_backend_migrations(_: argparse.Namespace) -> int:
|
||||
ensure_import_path()
|
||||
from backend.scripts.run_migrations import main as run_migrations_main
|
||||
|
||||
return run_migrations_main()
|
||||
|
||||
|
||||
def start_backend_daemon(args: argparse.Namespace) -> int:
|
||||
ensure_runtime_dirs()
|
||||
if BACKEND_PID.exists():
|
||||
@@ -260,6 +267,9 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
add_backend_args(backend)
|
||||
backend.set_defaults(func=run_backend)
|
||||
|
||||
backend_migrate = sub.add_parser("backend-migrate", help="run backend database migrations")
|
||||
backend_migrate.set_defaults(func=run_backend_migrations)
|
||||
|
||||
backend_daemon = sub.add_parser("backend-daemon", help="start backend in the background")
|
||||
backend_daemon.add_argument("--host", default="0.0.0.0")
|
||||
backend_daemon.add_argument("--port", type=int, default=BACKEND_PORT)
|
||||
|
||||
Reference in New Issue
Block a user