Build reusable bot framework
Some checks failed
CI / test (push) Has been cancelled
CI / compose-smoke (push) Has been cancelled

This commit is contained in:
Chelsea Lee
2026-07-19 21:53:24 -05:00
parent 7ecc1107b2
commit fbdf33e894
66 changed files with 8428 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
"""Command-line entry point for database migrations."""
import argparse
from core.migrations import MigrationError, migration_status, upgrade
def main(argv=None):
parser = argparse.ArgumentParser(description="Manage database migrations")
parser.add_argument("command", choices=("upgrade", "status"))
args = parser.parse_args(argv)
try:
if args.command == "upgrade":
applied = upgrade()
for migration in applied:
print(f"applied {migration.namespace}:{migration.version} {migration.name}")
if not applied:
print("database is up to date")
return 0
records = migration_status()
if not records:
print("no migrations found")
for record in records:
name = record["name"] or "<source missing>"
print(
f"{record['state']:<8} "
f"{record['namespace']}:{record['version']} {name}"
)
return 1 if any(row["state"] == "changed" for row in records) else 0
except MigrationError as error:
parser.exit(1, f"migration error: {error}\n")
if __name__ == "__main__":
raise SystemExit(main())