You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: CREATE DATABASE cannot executed within multi-command string.
Two ways:
Abandon checking the db exists
Take out the exists checking to QueryInterface. It's take two queries in one time API invoking.
createDatabase(database,options){options=options||{};constsql=this.QueryGenerator.createDatabaseQuery(database,options);if(IS_POSTGRES){returnthis.sequelize.query(`SELECT 1 as exists FROM pg_database WHERE datname = '${database}'`).then(result=>{if(result[0].exists!==1){returnthis.sequelize.query(sql,options);}});}else{returnthis.sequelize.query(sql,options);}}
Activity
ALiangLiang commentedon Oct 15, 2018
Note:
CREATE DATABASEcannot executed within multi-command string.Two ways:
I prefer method 2.
sushantdhiman commentedon Oct 15, 2018
Yeah, go with simplest for now