Skip to content

Drivine 0.9.0, with the store layout migration it needs on Postgres - #78

Open
jasperblues wants to merge 1 commit into
mainfrom
drivine-0.9.0
Open

jasperblues wants to merge 1 commit into
mainfrom
drivine-0.9.0

Conversation

@jasperblues

Copy link
Copy Markdown
Contributor

Moves Drivine from 0.6.0 to 0.9.0, in the pom and in codegen-gradle.

Warning

Don't deploy before prod's database is migrated. From 0.8.0 Drivine keeps a Postgres graph in store layout 2, and refuses one written in layout 1 on its first connection. Prod's Cloud SQL database was written by 0.6.0, in layout 1. Deployed as it is, this fails at startup with StoreLayoutException: The graph 'drivine' on Postgres was written in store layout 1….

What's here

  • The version bumps, and an updated note in the pom.
  • StoreLayoutMigrationRunner: an env-gated test class, like Neo4jToPostgresMigration, that runs Drivine's StoreLayoutMigration. It declares every @NodeFragment under com.embabel (guide's, the chat store's and the RAG graph's), so their dates, moments and floats are rewritten as their kinds. It is a dry run unless LAYOUT_MIGRATE=true. See Drivine's guide to migrating a store layout.
  • 0.9.0 also makes a plain-string statement Cypher on Postgres. Guide sends no SQL as a plain string, so nothing changes for that.

Goes with embabel/embabel-agent-rag-graph#82 and embabel/embabel-chat-store#56. Merge those first, so this builds against their 0.9.0 snapshots.

Tested

  • ./mvnw verify: 211 tests passed, 1 skipped (MigratedDataReadBackTest, which is env-gated).
  • A rehearsal on a scratch Postgres:
    1. Guide on 0.6.0 started against it, and the latest seed-postgres artifact was applied: 3,012 nodes and 4,363 edges.
    2. Guide on 0.9.0 refused to start on it, as above.
    3. The runner's dry run was clean (no invalid values, undeclared candidates or collisions), and the real run ended MIGRATED.
    4. Guide on 0.9.0 then started. The personas written on 0.6.0 read back, register, login and sessions worked, and docs_textSearch and docs_vectorSearch over MCP returned the migrated chunks.
  • Not yet covered: that database held no chats, so no values were rewritten. Prod's sessions and messages have createdAt dates that will be. Rehearse once on a pg_dump of prod before the cutover.

Runbook

  1. Rehearse on a copy of prod. Run pg_dump -t 'drivine_*' through cloud-sql-proxy, restore it locally, then run the dry run and the migration below against the copy. Start guide on this branch against it, and drop the copy afterwards (it holds users' data).
  2. Freeze writes: gcloud run services update embabel-guide --ingress=internal. The migration refuses a graph that is written to while it runs.
  3. Back up Cloud SQL, with an on-demand backup or pg_dump -t 'drivine_*'.
  4. Dry run, then migrate, through cloud-sql-proxy. The migration takes two connections, which the pool cap of 5 allows.
    LAYOUT_POSTGRES_URL=jdbc:postgresql://localhost:5432/guide LAYOUT_POSTGRES_USERNAME=guide LAYOUT_POSTGRES_PASSWORD=… \
    ./mvnw -q test -Dtest=StoreLayoutMigrationRunner -Dsurefire.failIfNoSpecifiedTests=false
    # read the report, then the same with LAYOUT_MIGRATE=true; it must end MIGRATED
  5. Deploy this branch's image. It remakes the indexes the migration dropped as it starts. Then reopen ingress.
  6. Seed: the nightly export runs with guide's own Drivine, so from this merge it is written in layout 2. Hold the hub's apply-seed until prod is migrated, so the two layouts don't mix.

Rollback: the migration has no down-migration. Restore the backup from step 3, then move traffic back to the 0.6.0 revision.

🤖 Generated with Claude Code

https://claude.ai/code/session_01F8aCDTpKMpmaai34YTCX4y

Moves Drivine from 0.6.0 to 0.9.0 in the pom and the codegen build.
From 0.8.0 Drivine keeps a Postgres graph in store layout 2 and refuses
one written in layout 1, as prod's was by 0.6.0. StoreLayoutMigrationRunner
migrates it once, in place, declaring every @NodeFragment on the classpath:
a dry run by default, writing only with LAYOUT_MIGRATE=true.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F8aCDTpKMpmaai34YTCX4y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant