Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

adapt(control-api): declare legacyVersions for renamed oauth grants migration

Diego Zacarias978349855e49
diff --git a/control-api/src/db.ts b/control-api/src/db.ts
index ced7f8a51..ae0e7ea50 100644
--- a/control-api/src/db.ts
+++ b/control-api/src/db.ts
@@ -5934,6 +5934,17 @@ export const CONTROL_API_MIGRATIONS: DbMigration[] = [
},
{
version: '0101_oauth_grants_owner_generalization',
+ // Renamed twice while rebasing onto dev: 0091 -> 0100 -> 0101 (each dev sync
+ // collided with a migration dev landed at the same number). Environments where
+ // the feature branch already deployed recorded it under an earlier name (the
+ // dev cluster most likely as 0100_...). legacyVersions lets the runner mark
+ // 0101 applied from that prior row instead of re-running the DDL and leaving an
+ // orphan schema_migrations entry. Both names are unique to this migration
+ // (dev's 0100 is 0100_seed_minimax_allowed_model), so there is no false-skip.
+ legacyVersions: [
+ '0100_oauth_grants_owner_generalization',
+ '0091_oauth_grants_owner_generalization',
+ ],
apply: applyOAuthGrantsOwnerGeneralization,
},
]
diff --git a/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts b/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts
index 6b7ce605c..6639885ee 100644
--- a/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts
+++ b/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts
@@ -9,7 +9,7 @@ const mockPoolCtor = vi.fn(function MockPool() {
vi.mock('pg', () => ({ Pool: mockPoolCtor }))
-describe('0091 oauth_grants owner generalization migration', () => {
+describe('0101 oauth_grants owner generalization migration', () => {
beforeEach(() => {
vi.resetModules()
vi.clearAllMocks()
@@ -25,6 +25,20 @@ describe('0091 oauth_grants owner generalization migration', () => {
expect(versions).toContain('0100_seed_minimax_allowed_model')
})
+ it('carries its prior names as legacyVersions so a deploy that already ran it is not re-executed', async () => {
+ // Renamed 0091 -> 0100 -> 0101 across dev syncs. Environments that recorded an
+ // earlier name (the dev cluster) must mark 0101 applied from that row instead
+ // of re-running the DDL. See applyPendingMigrations' legacyVersions branch.
+ const { CONTROL_API_MIGRATIONS } = await import('../src/db.js')
+ const migration = CONTROL_API_MIGRATIONS.find(
+ m => m.version === '0101_oauth_grants_owner_generalization'
+ )
+ expect(migration?.legacyVersions).toEqual([
+ '0100_oauth_grants_owner_generalization',
+ '0091_oauth_grants_owner_generalization',
+ ])
+ })
+
it('adds owner_kind/context_id/bootstrapped_by, replaces the kind CHECK to admit shared, and rebuilds uniqueness', async () => {
const { initDb } = await import('../src/db.js')
await initDb()
@@ -32,7 +46,7 @@ describe('0091 oauth_grants owner generalization migration', () => {
const migration = sqls.find(
sql => sql.includes('ADD COLUMN IF NOT EXISTS owner_kind') && sql.includes('oauth_grants')
)
- expect(migration, 'the 0091 DDL was applied').toBeDefined()
+ expect(migration, 'the oauth_grants generalization DDL was applied').toBeDefined()
const ddl = migration as string
// New columns (idempotent).