fix: add schema (#1464)

* fix: add schema

* chore: format
This commit is contained in:
ChengLei Shao 2023-02-18 09:27:54 +08:00 committed by GitHub
parent b4641eb0d5
commit 43e52843fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View File

@ -5,7 +5,7 @@ export default class DatabaseUtils {
constructor(public db: Database) {} constructor(public db: Database) {}
addSchema(tableName, schema?) { addSchema(tableName, schema?) {
if (this.db.options.schema) { if (this.db.options.schema && !schema) {
schema = this.db.options.schema; schema = this.db.options.schema;
} }
@ -13,7 +13,7 @@ export default class DatabaseUtils {
// @ts-ignore // @ts-ignore
tableName = this.db.sequelize.getQueryInterface().queryGenerator.addSchema({ tableName = this.db.sequelize.getQueryInterface().queryGenerator.addSchema({
tableName, tableName,
_schema: this.db.options.schema, _schema: schema,
}); });
} }

View File

@ -15,7 +15,7 @@ import {
Sequelize, Sequelize,
SyncOptions, SyncOptions,
Transactionable, Transactionable,
Utils Utils,
} from 'sequelize'; } from 'sequelize';
import { SequelizeStorage, Umzug } from 'umzug'; import { SequelizeStorage, Umzug } from 'umzug';
import { Collection, CollectionOptions, RepositoryType } from './collection'; import { Collection, CollectionOptions, RepositoryType } from './collection';
@ -58,7 +58,7 @@ import {
SyncListener, SyncListener,
UpdateListener, UpdateListener,
UpdateWithAssociationsListener, UpdateWithAssociationsListener,
ValidateListener ValidateListener,
} from './types'; } from './types';
import { patchSequelizeQueryInterface, snakeCase } from './utils'; import { patchSequelizeQueryInterface, snakeCase } from './utils';
@ -174,6 +174,7 @@ export class Database extends EventEmitter implements AsyncEmitter {
constructor(options: DatabaseOptions) { constructor(options: DatabaseOptions) {
super(); super();
this.version = new DatabaseVersion(this); this.version = new DatabaseVersion(this);
const opts = { const opts = {

View File

@ -52,10 +52,11 @@ export class AppManager extends EventEmitter {
return server.listen(...args); return server.listen(...args);
} }
async getApplication(appName: string): Promise<null | Application> { async getApplication(appName: string, options = {}): Promise<null | Application> {
await this.emitAsync('beforeGetApplication', { await this.emitAsync('beforeGetApplication', {
appManager: this, appManager: this,
name: appName, name: appName,
options,
}); });
return this.applications.get(appName); return this.applications.get(appName);

View File

@ -14,7 +14,7 @@ import {
beforeCreateForChildrenCollection, beforeCreateForChildrenCollection,
beforeCreateForReverseField, beforeCreateForReverseField,
beforeDestroyForeignKey, beforeDestroyForeignKey,
beforeInitOptions beforeInitOptions,
} from './hooks'; } from './hooks';
import { InheritedCollection } from '@nocobase/database'; import { InheritedCollection } from '@nocobase/database';