fix(server): handle startup reindexing after failed model change (#18688)

drop constraint
This commit is contained in:
Mert 2025-05-27 12:36:30 -04:00 committed by GitHub
parent 6abcfaef99
commit 4794a1a092
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -247,7 +247,10 @@ export class DatabaseRepository {
return;
}
const dimSize = await this.getDimensionSize(table);
await sql`DROP INDEX IF EXISTS ${sql.raw(indexName)}`.execute(this.db);
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) => {
if (!rows.some((row) => row.columnName === 'embedding')) {
this.logger.warn(`Column 'embedding' does not exist in table '${table}', truncating and adding column.`);