Skip to content

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

TypeScript

fix(control-api): sync-m1 sequence entity-change migration after dev

Josué6d4eac1195e3
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 8e97d3837..15465495b 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.651",
+ "version": "0.1.653",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.651",
+ "version": "0.1.653",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",
diff --git a/control-api/package.json b/control-api/package.json
index 2cdde3af5..99dedcfef 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.651",
+ "version": "0.1.653",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/src/db.ts b/control-api/src/db.ts
index 5117060a5..94d93020d 100644
--- a/control-api/src/db.ts
+++ b/control-api/src/db.ts
@@ -6262,10 +6262,11 @@ export const CONTROL_API_MIGRATIONS: DbMigration[] = [
apply: applyControlAdminReplaceInviterAcceptGuard,
},
{
- version: '0117_durable_entity_change_feed',
- // The feature branch originally recorded this schema as 0116. Retain that
- // applied-migration identity so a previously deployed branch is not rerun.
- legacyVersions: ['0116_durable_entity_change_feed'],
+ version: '0119_durable_entity_change_feed',
+ // This feature was deployed both before the two replace-inviter migrations
+ // and at its original 0117 slot. Preserve both identities so the sync does
+ // not rerun entity-change DDL in either previously deployed environment.
+ legacyVersions: ['0116_durable_entity_change_feed', '0117_durable_entity_change_feed'],
apply: applyEntityChangeSchema,
},
]
diff --git a/control-api/test/db.migrationsOrder.test.ts b/control-api/test/db.migrationsOrder.test.ts
index 8d322881e..1e8d5e71d 100644
--- a/control-api/test/db.migrationsOrder.test.ts
+++ b/control-api/test/db.migrationsOrder.test.ts
@@ -59,35 +59,40 @@ describe('CONTROL_API_MIGRATIONS ordering invariant', () => {
expect(currentCollisions).toEqual([])
})
- it('recognizes the previously deployed entity-change migration without reapplying its DDL', async () => {
+ it('recognizes both previously deployed entity-change migration versions without reapplying DDL', async () => {
const { CONTROL_API_MIGRATIONS, initDb } = await import('../src/db.js')
const migration = CONTROL_API_MIGRATIONS.find(
- candidate => candidate.version === '0117_durable_entity_change_feed'
+ candidate => candidate.version === '0119_durable_entity_change_feed'
)
- expect(migration?.legacyVersions).toEqual(['0116_durable_entity_change_feed'])
-
- const appliedVersions = CONTROL_API_MIGRATIONS.filter(
- candidate => candidate.version !== migration?.version
- ).map(candidate => ({ version: candidate.version }))
- appliedVersions.push({ version: '0116_durable_entity_change_feed' })
- const query = vi.fn(async (sql: string) =>
- sql.includes('SELECT version FROM schema_migrations')
- ? { rows: appliedVersions, rowCount: appliedVersions.length }
- : { rows: [], rowCount: 0 }
- )
- const release = vi.fn()
-
- await initDb({ connect: vi.fn().mockResolvedValue({ query, release }) } as never)
-
- const statements = query.mock.calls.map(([sql]) => sql)
- expect(statements).not.toContainEqual(
- expect.stringContaining('CREATE TABLE IF NOT EXISTS entity_change_feed')
- )
- expect(query).toHaveBeenCalledWith(
- expect.stringContaining('INSERT INTO schema_migrations(version)'),
- ['0117_durable_entity_change_feed']
- )
- expect(release).toHaveBeenCalledOnce()
+ expect(migration?.legacyVersions).toEqual([
+ '0116_durable_entity_change_feed',
+ '0117_durable_entity_change_feed',
+ ])
+
+ for (const legacyVersion of migration?.legacyVersions ?? []) {
+ const appliedVersions = CONTROL_API_MIGRATIONS.filter(
+ candidate => candidate.version !== migration?.version
+ ).map(candidate => ({ version: candidate.version }))
+ appliedVersions.push({ version: legacyVersion })
+ const query = vi.fn(async (sql: string) =>
+ sql.includes('SELECT version FROM schema_migrations')
+ ? { rows: appliedVersions, rowCount: appliedVersions.length }
+ : { rows: [], rowCount: 0 }
+ )
+ const release = vi.fn()
+
+ await initDb({ connect: vi.fn().mockResolvedValue({ query, release }) } as never)
+
+ const statements = query.mock.calls.map(([sql]) => sql)
+ expect(statements).not.toContainEqual(
+ expect.stringContaining('CREATE TABLE IF NOT EXISTS entity_change_feed')
+ )
+ expect(query).toHaveBeenCalledWith(
+ expect.stringContaining('INSERT INTO schema_migrations(version)'),
+ ['0119_durable_entity_change_feed']
+ )
+ expect(release).toHaveBeenCalledOnce()
+ }
})
it('requires 0116_mcp_secret_rollback_permits to persist expiring rollback permits', async () => {
diff --git a/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts b/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts
index 3b5d207b7..61adb0e11 100644
--- a/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts
+++ b/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts
@@ -35,9 +35,9 @@ describe('0101 oauth_grants owner generalization migration', () => {
expect(versions.indexOf('0108_llm_provider_attempts_sdk_link_on_delete_set_null')).toBeLessThan(
versions.indexOf('0116_mcp_secret_rollback_permits')
)
- expect(versions).toContain('0117_durable_entity_change_feed')
+ expect(versions).toContain('0119_durable_entity_change_feed')
expect(versions.indexOf('0116_mcp_secret_rollback_permits')).toBeLessThan(
- versions.indexOf('0117_durable_entity_change_feed')
+ versions.indexOf('0119_durable_entity_change_feed')
)
expect(versions.indexOf('0100_seed_minimax_allowed_model')).toBeLessThan(
versions.indexOf('0106_oauth_grants_owner_generalization')