Skip to content

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

TypeScript

test(control-api): verify merged entity change migration alias

Josué55b16c216394
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index c590eda6b..f95b80ddd 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.644",
+ "version": "0.1.645",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.644",
+ "version": "0.1.645",
"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 f6e9dac46..f86280923 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.644",
+ "version": "0.1.645",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/db.migrationsOrder.test.ts b/control-api/test/db.migrationsOrder.test.ts
index 61f5f25c0..8d322881e 100644
--- a/control-api/test/db.migrationsOrder.test.ts
+++ b/control-api/test/db.migrationsOrder.test.ts
@@ -59,6 +59,37 @@ describe('CONTROL_API_MIGRATIONS ordering invariant', () => {
expect(currentCollisions).toEqual([])
})
+ it('recognizes the previously deployed entity-change migration without reapplying its 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'
+ )
+ 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()
+ })
+
it('requires 0116_mcp_secret_rollback_permits to persist expiring rollback permits', async () => {
const { CONTROL_API_MIGRATIONS } = await import('../src/db.js')
// Renumbered twice while syncing onto dev: 0101 -> 0109 -> 0116. The earlier