Skip to content

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

TypeScript

fix(control-api): restore member-registration revoke migration

Alfredo Lopez0b92b2b14129
diff --git a/control-api/src/db.ts b/control-api/src/db.ts
index 2bb3c39b5..a33135440 100644
--- a/control-api/src/db.ts
+++ b/control-api/src/db.ts
@@ -4747,6 +4747,18 @@ export const CONTROL_API_MIGRATIONS: DbMigration[] = [
`)
},
},
+ {
+ version: '0070_member_registration_runtime_delete_revoke',
+ apply: async db => {
+ // 0069 granted DELETE to the runtime role. Credential revocation is an
+ // UPDATE, so remove the unnecessary destructive privilege without
+ // rewriting a migration that may already be recorded in deployed DBs.
+ await db.query(`
+ REVOKE DELETE ON TABLE member_registration_credentials
+ FROM control_api_runtime;
+ `)
+ },
+ },
]
async function consolidateWorkflowAllowedUsersToTriggers(db: DbClient): Promise<void> {
diff --git a/control-api/test/db.ready.test.ts b/control-api/test/db.ready.test.ts
index f4d0020fa..2d99f91c1 100644
--- a/control-api/test/db.ready.test.ts
+++ b/control-api/test/db.ready.test.ts
@@ -7,7 +7,7 @@ describe('assertDbReady', () => {
await expect(assertDbReady({ query })).resolves.toBeUndefined()
expect(query).toHaveBeenCalledWith(expect.stringContaining('schema_migrations'), [
- '0069_member_registration_runtime_access',
+ '0070_member_registration_runtime_delete_revoke',
])
})
@@ -15,7 +15,7 @@ describe('assertDbReady', () => {
const query = vi.fn().mockResolvedValue({ rows: [{ ready: false }], rowCount: 1 })
await expect(assertDbReady({ query })).rejects.toThrow(
- 'migration 0069_member_registration_runtime_access is required'
+ 'migration 0070_member_registration_runtime_delete_revoke is required'
)
})
})
diff --git a/control-api/test/db.runtimeAccessMigrations.test.ts b/control-api/test/db.runtimeAccessMigrations.test.ts
index a768f9a3d..a702f8766 100644
--- a/control-api/test/db.runtimeAccessMigrations.test.ts
+++ b/control-api/test/db.runtimeAccessMigrations.test.ts
@@ -38,4 +38,20 @@ describe('runtime access migrations', () => {
'GRANT USAGE, SELECT ON SEQUENCE member_registration_credentials_id_seq'
)
})
+
+ it('0070 revokes DELETE while retaining the control-api runtime table boundary', async () => {
+ const { initDb } = await import('../src/db.js')
+ await initDb()
+
+ const sqls = clientQuery.mock.calls.map(([sql]) => String(sql))
+ const deleteRevocation = sqls.find(sql =>
+ sql.includes('REVOKE DELETE ON TABLE member_registration_credentials')
+ )
+ const recordedVersions = clientQuery.mock.calls
+ .filter(([sql]) => String(sql).includes('INSERT INTO schema_migrations'))
+ .map(([, params]) => (Array.isArray(params) ? params[0] : undefined))
+
+ expect(deleteRevocation).toContain('FROM control_api_runtime')
+ expect(recordedVersions).toContain('0070_member_registration_runtime_delete_revoke')
+ })
})