Skip to content

Commit

Permalink
Update database commands for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Baker committed Sep 21, 2017
1 parent 0846642 commit 842a428
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/commands/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ exports.handler = async function (args) {
const sequelize = getDatabaseLessSequelize();
const config = helpers.config.readConfig();

let dbName = config.database;

if (config.dialect === 'postgres') {
dbName = `"${dbName}"`;
}

switch (command) {
case 'db:create':
await sequelize.query(`CREATE DATABASE ${config.database}`, {
await sequelize.query(`CREATE DATABASE ${dbName}`, {
type: sequelize.QueryTypes.RAW
}).catch(e => {
helpers.view.error(`Error: ${e.message}`);
Expand All @@ -34,7 +40,7 @@ exports.handler = async function (args) {

break;
case 'db:drop':
await sequelize.query(`DROP DATABASE ${config.database}`, {
await sequelize.query(`DROP DATABASE ${dbName}`, {
type: sequelize.QueryTypes.RAW
}).catch(e => {
helpers.view.error(`Error: ${e.message}`);
Expand Down

0 comments on commit 842a428

Please sign in to comment.