Browse Source

fix: SQLite hacky solution for alter table issue

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6513/head
mertmit 11 months ago committed by sreehari jayaraj
parent
commit
fcf2082a10
  1. 11
      packages/nocodb/src/db/sql-client/lib/sqlite/SqliteClient.ts

11
packages/nocodb/src/db/sql-client/lib/sqlite/SqliteClient.ts

@ -1619,6 +1619,15 @@ class SqliteClient extends KnexClient {
await this.sqlClient.raw('PRAGMA legacy_alter_table = ON;');
/*
This is a hack to avoid the following error:
- SQLITE_ERROR: duplicate column name: column_name
Somehow this error is thrown when we drop a column and add a new column with the same name right after it.
TODO - Find a better solution for this.
*/
await this.sqlClient.raw('SELECT * FROM ?? LIMIT 1', [args.table]);
const trx = await this.sqlClient.transaction();
try {
@ -1650,7 +1659,7 @@ class SqliteClient extends KnexClient {
await trx.commit();
} catch (e) {
await trx.rollback();
log.ppe(e, _func);
// log.ppe(e, _func);
throw e;
} finally {
if (fkCheckEnabled)

Loading…
Cancel
Save