diff --git a/packages/core/database/src/sync-runner.ts b/packages/core/database/src/sync-runner.ts index fb0f1faab9..b2c2a36b41 100644 --- a/packages/core/database/src/sync-runner.ts +++ b/packages/core/database/src/sync-runner.ts @@ -7,14 +7,14 @@ * For more information, please refer to: https://www.nocobase.com/agreement. */ -import { Model } from './model'; +import { isPlainObject } from '@nocobase/utils'; +import { Model as SequelizeModel } from 'sequelize'; import { Collection } from './collection'; import Database from './database'; -import { InheritedSyncRunner } from './inherited-sync-runner'; -import { InheritedCollection } from './inherited-collection'; -import { Model as SequelizeModel } from 'sequelize'; import { ZeroColumnTableError } from './errors/zero-column-table-error'; -import { isPlainObject } from '@nocobase/utils'; +import { InheritedCollection } from './inherited-collection'; +import { InheritedSyncRunner } from './inherited-sync-runner'; +import { Model } from './model'; export class SyncRunner { private readonly collection: Collection; @@ -74,14 +74,17 @@ export class SyncRunner { throw e; } + let beforeColumns; + try { - const beforeColumns = await this.queryInterface.describeTable(this.tableName, options); + beforeColumns = await this.queryInterface.describeTable(this.tableName, options); + } catch (error) { + // continue + } + + if (beforeColumns) { await this.handlePrimaryKeyBeforeSync(beforeColumns, options); await this.handleUniqueFieldBeforeSync(beforeColumns, options); - } catch (e) { - if (!e.message.includes('No description found')) { - throw e; - } } const syncResult = await this.performSync(options);