Skip to content

Commit 4794a1a

Browse files
authored
fix(server): handle startup reindexing after failed model change (#18688)
drop constraint
1 parent 6abcfae commit 4794a1a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/src/repositories/database.repository.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ export class DatabaseRepository {
247247
return;
248248
}
249249
const dimSize = await this.getDimensionSize(table);
250-
await sql`DROP INDEX IF EXISTS ${sql.raw(indexName)}`.execute(this.db);
250+
await this.db.schema.dropIndex(indexName).ifExists().execute();
251+
if (table === 'smart_search') {
252+
await this.db.schema.alterTable(table).dropConstraint('dim_size_constraint').ifExists().execute();
253+
}
251254
await this.db.transaction().execute(async (tx) => {
252255
if (!rows.some((row) => row.columnName === 'embedding')) {
253256
this.logger.warn(`Column 'embedding' does not exist in table '${table}', truncating and adding column.`);

0 commit comments

Comments
 (0)