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) {}
addSchema(tableName, schema?) {
if (this.db.options.schema) {
if (this.db.options.schema && !schema) {
schema = this.db.options.schema;
}
@ -13,7 +13,7 @@ export default class DatabaseUtils {
// @ts-ignore
tableName = this.db.sequelize.getQueryInterface().queryGenerator.addSchema({
tableName,
_schema: this.db.options.schema,
_schema: schema,
});
}

View File

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

View File

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

View File

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