Repository navigation
fix(migrations): add connector settings to existing databases - #13
Merged
Merged
Conversation
akazwz
reviewed
Oct 6, 2026
akazwz
left a comment
Member
There was a problem hiding this comment.
看过了,没什么问题。有两点你看要不要处理一下:
docs/development.md里还写着不承诺原地升级,要不要顺手改一下?- 回退的时候 2 → 1 好像没有入口,是不是直接手动改
schema_migrations就行?
Member
Author
在
|
akazwz
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The v0.2.0 database is already at migration 1, but does not contain
connector_settings. That table was later added directly to migration 0001. Upgrading an existing database therefore skips its creation: the server starts and/healthzreturns 200, while the authenticated connector catalog returns 500. A fresh database works.This blocks releasing the fixes from #11 and #12 to installations using the historical schema. Refs felinics/Memoh#1168; the original reporter's database has not been inspected.
Change
Add migration 0002 to create
connector_settingsif it is missing. Keep 0001 unchanged and preserve existing settings, tokens, connector configuration, and connections. The 0002 down migration retains the table because current version-1 databases already own it; 0001 down still performs complete teardown.Add a byte-identical v0.2.0 SQL fixture and PostgreSQL regressions for legacy upgrades, current version-1 databases, repeated and concurrent startup, schema isolation, and 2 → 1 → 2 transitions.
Document in
docs/development.mdthat existing databases upgrade in place, that a migration is frozen once merged (every push tomainpublisheslatest), and how to roll back.AGENTS.mdnow says never to edit a merged migration, the mistake that leftconnector_settingsout of upgraded databases.Validation
TEST_DATABASE_URL=<isolated PostgreSQL> GOFLAGS=-count=1 mise run test: all Go modules passed.packages/service,go test -race . -count=1 -timeout 60sand scopedgo vet .passed.go test -race -run '^TestMigrate' -count=5 -timeout=90s -v .: 45 top-level passes, no skips or race reports.vcs.revision=d87de04…,vcs.modified=false, image binary SHA-256 verified) of the committed API binary and PostgreSQL 18: historical v0.2.0, current version 1 with GitHub disabled, and fresh database all passed first startup and restart. Bearer-authenticated/v1/connectorsand cookie-authenticated/admin/connectorsreturned 200; unauthenticated catalog access returned 401.search_path=connect_it, plus a host-ownedpublic.schema_migrationsat version 2): swapping only the image exits withno migration found for version 2. Both the documented SQL in a plainpsqlsession andmigrate/migrate:v4.19.1 … goto 1returned the service schema to1|fwithout touching the host table. The old image then served/healthzand bearer/v1/connectorswith 200 (401 unauthenticated), and upgrading again returned to2|fwithconnector_settingsunchanged.The Docker test used synthetic credentials in a disposable database. The local running GitHub integration remains on the official image from #12; no production database was changed.
Rollback and release
Older binaries only embed migration 0001 and refuse to start at database version 2, so changing only the image is insufficient. The binary only migrates up: stop every instance, then revert the service's schema by hand. 0002's down step keeps the table and its settings, so 2 → 1 is one statement (replace
connect_itwith the service's schema; expectUPDATE 1):The table name must be schema-qualified: in a database shared with a host application, a plain
psqlsession resolvesschema_migrationsto the host's table.docs/development.mdalso documents the generalmigrate … goto <version>path. After rolling back to v0.1.1 or v0.2.0, which ignoreconnector_settings, disabled connectors are available again until the next upgrade.Release v0.3.1 after this change merges, then record the released source SHA and image digest for downstream Memoh and Memoh-Cloud upgrades.