build(db): add Alembic scaffolding + baseline migration

Introduce Alembic at v1. Migrations live inside the package
(decnet/web/db/migrations) so they ship with installs; alembic.ini at the
repo root drives the CLI. env.py is async and dual-backend, selecting the
engine from DECNET_DB_TYPE (mirroring db/factory.py) and reusing the app's
own connection when run programmatically.

The baseline captures all 39 tables. _BIG_TEXT round-trips as
Text().with_variant(MEDIUMTEXT, 'mysql'), so both backends get the right
column type from the migration. kd_digraph_simhash gains a sqlite BLOB
variant: BINARY(8) reflects as NUMERIC on SQLite and would otherwise trip
'alembic check' forever.
This commit is contained in:
2026-06-16 16:30:29 -04:00
parent 4f141c1a54
commit ef4d67cbef
8 changed files with 1392 additions and 3 deletions

View File

@@ -34,6 +34,9 @@ dependencies = [
"psutil>=5.9.0",
"python-dotenv>=1.0.0",
"sqlmodel>=0.0.16",
# Schema migrations. Runtime dep (not dev-only): the API runs
# `alembic upgrade head` at boot for managed DBs (see db/migrate.py).
"alembic>=1.13",
"scapy>=2.6.1",
"orjson>=3.10",
"cryptography>=48.0.1",