Tasks: Fix init-db.sh — Correct Migration Paths + Delegate Postgres DDL to Django¶
Each task must reference one or more
FR-*/NFR-*/AC-*IDs from spec.md. CI'sspec_validator.pyenforces that every requirement inspec.mdis referenced by at least one task.
Conventions¶
- Status:
[ ]todo /[~]in-progress /[x]done. - Owner: GitHub handle or
@copilot/@agent:<role>. - Each task lists exact files to touch and how to verify.
T-001 — Fix NEO4J_MIGRATIONS path and replace Postgres psql loop¶
- Refs: FR-1, FR-2, FR-3, FR-4, FR-5, NFR-SEC-1, NFR-AUDIT-1, NFR-HITL-1, NFR-MIGRATION-SAFETY-1, AC-1, AC-2, AC-3, AC-4
- Owner: @copilot
- Status:
[x] - Files:
backend/scripts/init-db.sh(modify)- Steps:
- Change
NEO4J_MIGRATIONS="$REPO_ROOT/app/db/neo4j_migrations"toNEO4J_MIGRATIONS="$REPO_ROOT/law_ai/core/neo4j/migrations". - Remove the
PG_MIGRATIONSvariable and thefor f in "$PG_MIGRATIONS"/*.sqlloop entirely. - Add
DJANGO_SETTINGS_MODULE="${DJANGO_SETTINGS_MODULE:-law_ai.settings.dev}"export before themanage.pycall. - Replace the removed Postgres block with:
- Add a warning if the Cypher glob matches no files:
- Verify:
bash -n backend/scripts/init-db.shexits 0.grep -q "app/db/neo4j_migrations\|app/db/postgres_migrations" backend/scripts/init-db.shexits non-zero (old paths absent).grep -q "manage.py migrate" backend/scripts/init-db.shexits 0.
T-002 — Add or extend a test asserting the script correctness¶
- Refs: FR-1, FR-3, AC-3, AC-4, AC-5
- Owner: @copilot
- Status:
[x] - Files:
tests/test_configs.py(extend) ortests/test_init_db.py(new if a new file is cleaner)- Steps:
- Use
subprocess.run(["bash", "-n", "backend/scripts/init-db.sh"])and assert exit 0 (AC-4). - Read
backend/scripts/init-db.shas text and assert neitherapp/db/neo4j_migrationsnorapp/db/postgres_migrationsappears (AC-3). - Assert
manage.py migrateappears in the script text (AC-2). - Verify:
cd /Users/bamr87/law-ai && pytest tests/test_configs.py -q(ortest_init_db.py) green.
Done-When (Definition of Done)¶
- All tasks
[x]. - All
AC-*fromspec.mdcovered by passing tests. make lintgreen;pytest tests/test_configs.py(or equivalent) green.- LegalBench delta: 0 pp (no reasoning logic changed).
## Follow-ups Discoveredsection below populated.
Follow-ups Discovered¶
Append-only. Mirror each item into BACKLOG.md with a
BL-YYYYMMDD-NNid.
- BL-20260511-01 — infra, med — Add a real Cypher migration runner that records applied migrations in a
(:_Migration {id})Neo4j node so non-idempotent migrations (e.g. data back-fills) become safe later. Resolves overlap with BL-20260509-02. Surfaced in: specs/017-fix-init-db-sh implementation. - BL-20260511-02 — test-gap, low — Add a Docker-backed integration smoke test that runs
init-db.shagainst live Neo4j and Postgres containers and confirms all seven Cypher migrations were applied (SHOW CONSTRAINTS). Resolves overlap with BL-20260509-03. Surfaced in: specs/017-fix-init-db-sh implementation.