PEP-67: migrate-to-sqlite skips tables that don't exist in the legacy Postgres schema

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Асель 2026-11-14 03:35:53 +05:00
parent e2beb70dc4
commit 16a6fcf8ac

View File

@ -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) {