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:
2026-05-05 01:36:58 +08:00
parent e243dccfd7
commit 3ab845798d
21 changed files with 911 additions and 145 deletions
+5
View File
@@ -56,6 +56,11 @@ class BackendManagerUvTests(unittest.TestCase):
self.assertEqual(cmd[1:3], ["run", "python"])
self.assertEqual(cmd[3:5], [str(main.REPO_ROOT / "main.py"), "backend"])
def test_backend_migrate_command_is_registered(self) -> None:
args = main.build_parser().parse_args(["backend-migrate"])
self.assertIs(args.func, main.run_backend_migrations)
if __name__ == "__main__":
unittest.main()