Follow-up to #46 (PR #63). Runner.Run (internal/ent/migrate/runner.go) currently
takes a Postgres session advisory lock (pg_advisory_lock/pg_advisory_unlock)
inline to serialize concurrent migrators. That ties the coordination mechanism
directly to Postgres and makes Runner's apply logic (sequencing, error
propagation, unlock-on-cancel) hard to unit test without a real database.
Not blocking: today's Postgres advisory lock is correct and already covered by
an integration test (TestRunConcurrentCallersSerialize). This is a
testability/extensibility cleanup, not a bug fix.
Related: #48 (generalized Postgres job queue — same "don't hardcode Postgres
as the coordination primitive" theme, but for the ingest queue, not migration
locking).
Follow-up to #46 (PR #63).
Runner.Run(internal/ent/migrate/runner.go) currentlytakes a Postgres session advisory lock (
pg_advisory_lock/pg_advisory_unlock)inline to serialize concurrent migrators. That ties the coordination mechanism
directly to Postgres and makes
Runner's apply logic (sequencing, errorpropagation, unlock-on-cancel) hard to unit test without a real database.
Lockerinterface (Lock(ctx) error/Unlock(ctx) error) outof the advisory-lock code; keep the Postgres advisory lock as the default
implementation, injected via
RunnerOptions(struct-options pattern perCLAUDE.md), not hardcoded in
NewRunner.moqmock forLockersoRunner.Run's sequencing/errorhandling can be unit-tested with a fake lock, independent of the
integration test that already covers real Postgres concurrency
(
internal/ent/migrate/runner_integration_test.go).Consul, ...) later, without touching
Runner.Not blocking: today's Postgres advisory lock is correct and already covered by
an integration test (
TestRunConcurrentCallersSerialize). This is atestability/extensibility cleanup, not a bug fix.
Related: #48 (generalized Postgres job queue — same "don't hardcode Postgres
as the coordination primitive" theme, but for the ingest queue, not migration
locking).