diff --git a/packages/cli/src/migrate-to-sqlite.ts b/packages/cli/src/migrate-to-sqlite.ts index d02ee5cc..cf4feab2 100644 --- a/packages/cli/src/migrate-to-sqlite.ts +++ b/packages/cli/src/migrate-to-sqlite.ts @@ -38,6 +38,12 @@ export async function migrateToSqlite(sourceUrl: string, file: string): Promise< // One read-only snapshot of Postgres for all tables. await pg.begin("isolation level repeatable read read only", async (tx) => { for (const t of tablesInFkOrder()) { + // Tables born after the move to SQLite (PEP-67 subscriptions…) don't exist in Postgres. + const [{ found }] = await tx.unsafe(`select to_regclass($1) is not null as found`, [`public."${t.name}"`]); + if (!found) { + report.push({ name: t.name, source: 0, copied: 0 }); + continue; + } const rows = await tx.unsafe(`select * from "${t.name}"`); const cols = t.columns.filter((c) => rows.length === 0 || c.name in rows[0]!); if (rows.length) {