The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
test(db): cover 0050 migration replay
dotta1e76bbe38c69
diff --git a/packages/db/src/client.test.ts b/packages/db/src/client.test.tsindex 64b1caf1f7..81cc2acef9 100644--- a/packages/db/src/client.test.ts+++ b/packages/db/src/client.test.ts@@ -401,4 +401,70 @@ describeEmbeddedPostgres("applyPendingMigrations", () => {},20_000,);++ it(+ "replays migration 0050 safely when projects.env already exists",+ async () => {+ const connectionString = await createTempDatabase();++ await applyPendingMigrations(connectionString);++ const sql = postgres(connectionString, { max: 1, onnotice: () => {} });+ try {+ const stiffLuckmanHash = await migrationHash("0050_stiff_luckman.sql");++ await sql.unsafe(+ `DELETE FROM "drizzle"."__drizzle_migrations" WHERE hash = '${stiffLuckmanHash}'`,+ );++ const columns = await sql.unsafe<{ column_name: string }[]>(+ `+ SELECT column_name+ FROM information_schema.columns+ WHERE table_schema = 'public'+ AND table_name = 'projects'+ AND column_name = 'env'+ `,+ );+ expect(columns).toHaveLength(1);+ } finally {+ await sql.end();+ }++ const pendingState = await inspectMigrations(connectionString);+ expect(pendingState).toMatchObject({+ status: "needsMigrations",+ pendingMigrations: ["0050_stiff_luckman.sql"],+ reason: "pending-migrations",+ });++ await applyPendingMigrations(connectionString);++ const finalState = await inspectMigrations(connectionString);+ expect(finalState.status).toBe("upToDate");++ const verifySql = postgres(connectionString, { max: 1, onnotice: () => {} });+ try {+ const columns = await verifySql.unsafe<{ column_name: string; is_nullable: string; data_type: string }[]>(+ `+ SELECT column_name, is_nullable, data_type+ FROM information_schema.columns+ WHERE table_schema = 'public'+ AND table_name = 'projects'+ AND column_name = 'env'+ `,+ );+ expect(columns).toEqual([+ expect.objectContaining({+ column_name: "env",+ is_nullable: "YES",+ data_type: "jsonb",+ }),+ ]);+ } finally {+ await verifySql.end();+ }+ },+ 20_000,+ );});