Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-migration-033-runner-registration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"emdash": patch
---

Fixes migration 033 (optimize content indexes) not being registered in the static migration runner, so the composite and partial indexes it defines are now actually applied on startup.
2 changes: 2 additions & 0 deletions packages/core/src/database/migrations/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import * as m029 from "./029_redirects.js";
import * as m030 from "./030_widen_scheduled_index.js";
import * as m031 from "./031_bylines.js";
import * as m032 from "./032_rate_limits.js";
import * as m033 from "./033_optimize_content_indexes.js";

/**
* Migration provider that uses statically imported migrations.
Expand Down Expand Up @@ -72,6 +73,7 @@ class StaticMigrationProvider implements MigrationProvider {
"030_widen_scheduled_index": m030,
"031_bylines": m031,
"032_rate_limits": m032,
"033_optimize_content_indexes": m033,
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/tests/database/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ describe("Database Migrations", () => {
await expect(runMigrations(db)).resolves.not.toThrow();

const status = await getMigrationStatus(db);
expect(status.applied).toHaveLength(31); // 001_initial through 032_rate_limits (no 010)
expect(status.applied).toHaveLength(32); // 001_initial through 033_optimize_content_indexes (no 010)
});

it("should record migration in tracking table", async () => {
await runMigrations(db);

const records = await db.selectFrom("_emdash_migrations").selectAll().execute();

expect(records).toHaveLength(31);
expect(records).toHaveLength(32);
expect(records[0].name).toBe("001_initial");
expect(records[0].timestamp).toBeDefined();
expect(records[1].name).toBe("002_media_status");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describeEachDialect("Migrations", (dialect) => {

const migrations = await ctx.db.selectFrom("_emdash_migrations").selectAll().execute();

expect(migrations).toHaveLength(31);
expect(migrations).toHaveLength(32);
expect(migrations[0]?.name).toBe("001_initial");
});

Expand All @@ -85,7 +85,7 @@ describeEachDialect("Migrations", (dialect) => {

const migrations = await ctx.db.selectFrom("_emdash_migrations").selectAll().execute();

expect(migrations).toHaveLength(31);
expect(migrations).toHaveLength(32);
});

it("reports correct migration status", async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/tests/integration/database/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("Database Migrations (Integration)", () => {

const migrations = await db.selectFrom("_emdash_migrations").selectAll().execute();

expect(migrations).toHaveLength(31);
expect(migrations).toHaveLength(32);
expect(migrations[0]?.name).toBe("001_initial");
expect(migrations[0]?.timestamp).toBeDefined();
expect(migrations[1]?.name).toBe("002_media_status");
Expand Down Expand Up @@ -98,8 +98,8 @@ describe("Database Migrations (Integration)", () => {

const migrations = await db.selectFrom("_emdash_migrations").selectAll().execute();

// Should still only have thirty-one migration records
expect(migrations).toHaveLength(31);
// Should still only have thirty-two migration records
expect(migrations).toHaveLength(32);
});

it("should report correct migration status", async () => {
Expand Down
Loading