fix(db): keep plugin index names when moving plugin data to Postgres

The move now creates each index a plugin named under that name, so a later plugin migration that drops or alters it by name finds it on a moved install as on a fresh one.
This commit is contained in:
Maurice
2026-11-23 14:58:34 +01:00
parent 6a6c403860
commit 9c454a04e1
2 changed files with 12 additions and 6 deletions
@@ -151,7 +151,9 @@ function indexDdl(index: SqliteIndex, target: string, notes: string[], table: st
return null;
}
const columns = index.columns.map(quoteIdentifier).join(', ');
return `create ${index.unique ? 'unique ' : ''}index on ${target} (${columns})`;
// The plugin's own name, for a later migration to find; a UNIQUE constraint's index has none of its own.
const name = index.origin === 'c' ? `${quoteIdentifier(index.name)} ` : '';
return `create ${index.unique ? 'unique ' : ''}index ${name}on ${target} (${columns})`;
}
/** Plans the copy of one plugin's `plugin.db`: what to create in its schema and what to fill. */