fix: upgrade failed

This commit is contained in:
chenos 2023-09-24 11:41:26 +08:00
parent c4be5315ce
commit e522e1f742
3 changed files with 17 additions and 11 deletions

View File

@ -2,6 +2,7 @@ import { Logger } from '@nocobase/logger';
import { applyMixins, AsyncEmitter, requireModule } from '@nocobase/utils';
import merge from 'deepmerge';
import { EventEmitter } from 'events';
import { backOff } from 'exponential-backoff';
import glob from 'glob';
import lodash from 'lodash';
import { basename, isAbsolute, resolve } from 'path';
@ -69,7 +70,6 @@ import {
import { patchSequelizeQueryInterface, snakeCase } from './utils';
import { BaseValueParser, registerFieldValueParsers } from './value-parsers';
import { ViewCollection } from './view-collection';
import { backOff } from 'exponential-backoff';
export type MergeOptions = merge.Options;
@ -285,6 +285,8 @@ export class Database extends EventEmitter implements AsyncEmitter {
migrations: this.migrations.callback(),
context,
storage: new SequelizeStorage({
tableName: `${this.options.tablePrefix || ''}migrations`,
modelName: 'migrations',
...migratorOptions.storage,
sequelize: this.sequelize,
}),

View File

@ -14,6 +14,7 @@ import Koa, { DefaultContext as KoaDefaultContext, DefaultState as KoaDefaultSta
import compose from 'koa-compose';
import lodash from 'lodash';
import { createACL } from './acl';
import { AppCommand } from './app-command';
import { AppSupervisor } from './app-supervisor';
import { registerCli } from './commands';
import { ApplicationNotInstall } from './errors/application-not-install';
@ -22,7 +23,6 @@ import { ApplicationVersion } from './helpers/application-version';
import { Locale } from './locale';
import { Plugin } from './plugin';
import { InstallOptions, PluginManager } from './plugin-manager';
import { AppCommand } from './app-command';
const packageJson = require('../package.json');

View File

@ -93,15 +93,19 @@ export class PresetNocoBase extends Plugin {
}
async updateOrCreatePlugins() {
const repository = this.app.db.getRepository<Repository>('applicationPlugins');
return Promise.all(
this.allPlugins.map((values) =>
repository.updateOrCreate({
values,
filterKeys: ['name'],
}),
),
);
const repository = this.app.db.getRepository<any>('applicationPlugins');
await this.db.sequelize.transaction((transaction) => {
return Promise.all(
this.allPlugins.map((values) =>
repository.updateOrCreate({
transaction,
values,
filterKeys: ['name'],
}),
),
);
});
await this.app.reload();
}
async createIfNotExists() {