mirror of
https://github.com/immich-app/immich.git
synced 2026-02-28 09:38:43 +03:00
fix: include DROP INDEX in transaction to prevent missing index on rollback (#25399)
* fix: ERR_PNPM_ENOENT error while `make dev` on macOS. * fix: include `DROP INDEX` in transaction to prevent missing index on rollback. * chore: clean up this PR.
This commit is contained in:
@@ -248,11 +248,11 @@ export class DatabaseRepository {
|
||||
}
|
||||
const dimSize = await this.getDimensionSize(table);
|
||||
lists ||= this.targetListCount(await this.getRowCount(table));
|
||||
await this.db.schema.dropIndex(indexName).ifExists().execute();
|
||||
if (table === 'smart_search') {
|
||||
await this.db.schema.alterTable(table).dropConstraint('dim_size_constraint').ifExists().execute();
|
||||
}
|
||||
await this.db.transaction().execute(async (tx) => {
|
||||
await sql`DROP INDEX IF EXISTS ${sql.raw(indexName)}`.execute(tx);
|
||||
if (table === 'smart_search') {
|
||||
await sql`ALTER TABLE ${sql.raw(table)} DROP CONSTRAINT IF EXISTS dim_size_constraint`.execute(tx);
|
||||
}
|
||||
if (!rows.some((row) => row.columnName === 'embedding')) {
|
||||
this.logger.warn(`Column 'embedding' does not exist in table '${table}', truncating and adding column.`);
|
||||
await sql`TRUNCATE TABLE ${sql.raw(table)}`.execute(tx);
|
||||
|
||||
Reference in New Issue
Block a user