fix: upgrade failed
This commit is contained in:
parent
c4be5315ce
commit
e522e1f742
@ -2,6 +2,7 @@ import { Logger } from '@nocobase/logger';
|
|||||||
import { applyMixins, AsyncEmitter, requireModule } from '@nocobase/utils';
|
import { applyMixins, AsyncEmitter, requireModule } from '@nocobase/utils';
|
||||||
import merge from 'deepmerge';
|
import merge from 'deepmerge';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
import { backOff } from 'exponential-backoff';
|
||||||
import glob from 'glob';
|
import glob from 'glob';
|
||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
import { basename, isAbsolute, resolve } from 'path';
|
import { basename, isAbsolute, resolve } from 'path';
|
||||||
@ -69,7 +70,6 @@ import {
|
|||||||
import { patchSequelizeQueryInterface, snakeCase } from './utils';
|
import { patchSequelizeQueryInterface, snakeCase } from './utils';
|
||||||
import { BaseValueParser, registerFieldValueParsers } from './value-parsers';
|
import { BaseValueParser, registerFieldValueParsers } from './value-parsers';
|
||||||
import { ViewCollection } from './view-collection';
|
import { ViewCollection } from './view-collection';
|
||||||
import { backOff } from 'exponential-backoff';
|
|
||||||
|
|
||||||
export type MergeOptions = merge.Options;
|
export type MergeOptions = merge.Options;
|
||||||
|
|
||||||
@ -285,6 +285,8 @@ export class Database extends EventEmitter implements AsyncEmitter {
|
|||||||
migrations: this.migrations.callback(),
|
migrations: this.migrations.callback(),
|
||||||
context,
|
context,
|
||||||
storage: new SequelizeStorage({
|
storage: new SequelizeStorage({
|
||||||
|
tableName: `${this.options.tablePrefix || ''}migrations`,
|
||||||
|
modelName: 'migrations',
|
||||||
...migratorOptions.storage,
|
...migratorOptions.storage,
|
||||||
sequelize: this.sequelize,
|
sequelize: this.sequelize,
|
||||||
}),
|
}),
|
||||||
|
@ -14,6 +14,7 @@ import Koa, { DefaultContext as KoaDefaultContext, DefaultState as KoaDefaultSta
|
|||||||
import compose from 'koa-compose';
|
import compose from 'koa-compose';
|
||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
import { createACL } from './acl';
|
import { createACL } from './acl';
|
||||||
|
import { AppCommand } from './app-command';
|
||||||
import { AppSupervisor } from './app-supervisor';
|
import { AppSupervisor } from './app-supervisor';
|
||||||
import { registerCli } from './commands';
|
import { registerCli } from './commands';
|
||||||
import { ApplicationNotInstall } from './errors/application-not-install';
|
import { ApplicationNotInstall } from './errors/application-not-install';
|
||||||
@ -22,7 +23,6 @@ import { ApplicationVersion } from './helpers/application-version';
|
|||||||
import { Locale } from './locale';
|
import { Locale } from './locale';
|
||||||
import { Plugin } from './plugin';
|
import { Plugin } from './plugin';
|
||||||
import { InstallOptions, PluginManager } from './plugin-manager';
|
import { InstallOptions, PluginManager } from './plugin-manager';
|
||||||
import { AppCommand } from './app-command';
|
|
||||||
|
|
||||||
const packageJson = require('../package.json');
|
const packageJson = require('../package.json');
|
||||||
|
|
||||||
|
@ -93,15 +93,19 @@ export class PresetNocoBase extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateOrCreatePlugins() {
|
async updateOrCreatePlugins() {
|
||||||
const repository = this.app.db.getRepository<Repository>('applicationPlugins');
|
const repository = this.app.db.getRepository<any>('applicationPlugins');
|
||||||
|
await this.db.sequelize.transaction((transaction) => {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
this.allPlugins.map((values) =>
|
this.allPlugins.map((values) =>
|
||||||
repository.updateOrCreate({
|
repository.updateOrCreate({
|
||||||
|
transaction,
|
||||||
values,
|
values,
|
||||||
filterKeys: ['name'],
|
filterKeys: ['name'],
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
await this.app.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
async createIfNotExists() {
|
async createIfNotExists() {
|
||||||
|
Loading…
Reference in New Issue
Block a user