Skip to content

Commit 2582541

Browse files
committed
fix: broken syncs
1 parent 9774134 commit 2582541

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/BaseModel.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -761,18 +761,18 @@ export abstract class BaseModel<T> extends Model<BaseModel<T>> {
761761
*/
762762
public static syncView(options?: SyncOptions): Promise<any> {
763763
const self: any = this;
764+
// noinspection TypeScriptUnresolvedVariable
765+
const queryInterface = self.QueryInterface || self.queryInterface;
764766

765767
if (options && options.withoutDrop) {
766-
// noinspection TypeScriptUnresolvedVariable
767-
return self.QueryInterface.createView(
768+
return queryInterface.createView(
768769
self.getTableName(),
769770
self.getViewDefinition(),
770771
);
771772
}
772773

773-
// noinspection TypeScriptUnresolvedVariable
774-
return self.QueryInterface.dropView(self.getTableName())
775-
.then(() => self.QueryInterface.createView(
774+
return queryInterface.dropView(self.getTableName())
775+
.then(() => queryInterface.createView(
776776
self.getTableName(),
777777
self.getViewDefinition(),
778778
));
@@ -849,18 +849,19 @@ export abstract class BaseModel<T> extends Model<BaseModel<T>> {
849849
const indexName: string = options.name ||
850850
`${this.getTableName()}_${column}_idx${position}`;
851851
const chain = Promise.resolve(true);
852+
// noinspection TypeScriptUnresolvedVariable
853+
const queryInterface = self.QueryInterface || self.queryInterface;
852854

853855
if (!options.safe) {
854-
// noinspection TypeScriptUnresolvedVariable
855-
chain.then(() => self.QueryInterface.sequelize.query(`
856+
chain.then(() => queryInterface.sequelize.query(`
856857
DROP INDEX${options.concurrently
857858
? ' CONCURRENTLY' : ''} IF EXISTS "${indexName}"
858859
`));
859860
}
860861

861862
// tslint:disable-next-line:max-line-length
862863
// noinspection TypeScriptUnresolvedVariable,PointlessBooleanExpressionJS
863-
chain.then(() => self.QueryInterface.sequelize.query(`
864+
chain.then(() => queryInterface.sequelize.query(`
864865
CREATE${options.unique
865866
? ' UNIQUE' : ''} INDEX${options.concurrently
866867
? ' CONCURRENTLY' : ''}${options.safe

0 commit comments

Comments
 (0)