@@ -46,6 +46,10 @@ exports.handler = async function (args) {
4646 'template' ,
4747 ] ) ;
4848
49+ const queryInterface = sequelize . getQueryInterface ( ) ;
50+ const queryGenerator =
51+ queryInterface . queryGenerator || queryInterface . QueryGenerator ;
52+
4953 const query = getCreateDatabaseQuery ( sequelize , config , options ) ;
5054
5155 switch ( command ) {
@@ -62,9 +66,9 @@ exports.handler = async function (args) {
6266 case 'db:drop' :
6367 await sequelize
6468 . query (
65- `DROP DATABASE IF EXISTS ${ sequelize
66- . getQueryInterface ( )
67- . quoteIdentifier ( config . database ) } `,
69+ `DROP DATABASE IF EXISTS ${ queryGenerator . quoteIdentifier (
70+ config . database
71+ ) } `,
6872 {
6973 type : sequelize . QueryTypes . RAW ,
7074 }
@@ -80,41 +84,41 @@ exports.handler = async function (args) {
8084} ;
8185
8286function getCreateDatabaseQuery ( sequelize , config , options ) {
87+ const queryInterface = sequelize . getQueryInterface ( ) ;
88+ const queryGenerator =
89+ queryInterface . queryGenerator || queryInterface . QueryGenerator ;
90+
8391 switch ( config . dialect ) {
8492 case 'postgres' :
8593 case 'postgres-native' :
8694 return (
8795 'CREATE DATABASE ' +
88- sequelize . getQueryInterface ( ) . quoteIdentifier ( config . database ) +
96+ queryGenerator . quoteIdentifier ( config . database ) +
8997 ( options . encoding
90- ? ' ENCODING = ' +
91- sequelize . getQueryInterface ( ) . quoteIdentifier ( options . encoding )
98+ ? ' ENCODING = ' + queryGenerator . quoteIdentifier ( options . encoding )
9299 : '' ) +
93100 ( options . collate
94- ? ' LC_COLLATE = ' +
95- sequelize . getQueryInterface ( ) . quoteIdentifier ( options . collate )
101+ ? ' LC_COLLATE = ' + queryGenerator . quoteIdentifier ( options . collate )
96102 : '' ) +
97103 ( options . ctype
98- ? ' LC_CTYPE = ' +
99- sequelize . getQueryInterface ( ) . quoteIdentifier ( options . ctype )
104+ ? ' LC_CTYPE = ' + queryGenerator . quoteIdentifier ( options . ctype )
100105 : '' ) +
101106 ( options . template
102- ? ' TEMPLATE = ' +
103- sequelize . getQueryInterface ( ) . quoteIdentifier ( options . template )
107+ ? ' TEMPLATE = ' + queryGenerator . quoteIdentifier ( options . template )
104108 : '' )
105109 ) ;
106110
107111 case 'mysql' :
108112 return (
109113 'CREATE DATABASE IF NOT EXISTS ' +
110- sequelize . getQueryInterface ( ) . quoteIdentifier ( config . database ) +
114+ queryGenerator . quoteIdentifier ( config . database ) +
111115 ( options . charset
112116 ? ' DEFAULT CHARACTER SET ' +
113- sequelize . getQueryInterface ( ) . quoteIdentifier ( options . charset )
117+ queryGenerator . quoteIdentifier ( options . charset )
114118 : '' ) +
115119 ( options . collate
116120 ? ' DEFAULT COLLATE ' +
117- sequelize . getQueryInterface ( ) . quoteIdentifier ( options . collate )
121+ queryGenerator . quoteIdentifier ( options . collate )
118122 : '' )
119123 ) ;
120124
@@ -125,7 +129,7 @@ function getCreateDatabaseQuery(sequelize, config, options) {
125129 "')" +
126130 ' BEGIN' +
127131 ' CREATE DATABASE ' +
128- sequelize . getQueryInterface ( ) . quoteIdentifier ( config . database ) +
132+ queryGenerator . quoteIdentifier ( config . database ) +
129133 ( options . collate ? ' COLLATE ' + options . collate : '' ) +
130134 ' END;'
131135 ) ;
@@ -135,8 +139,7 @@ function getCreateDatabaseQuery(sequelize, config, options) {
135139 `Dialect ${ config . dialect } does not support db:create / db:drop commands`
136140 ) ;
137141 return (
138- 'CREATE DATABASE ' +
139- sequelize . getQueryInterface ( ) . quoteIdentifier ( config . database )
142+ 'CREATE DATABASE ' + queryGenerator . quoteIdentifier ( config . database )
140143 ) ;
141144 }
142145}
0 commit comments