Skip to content

feat(db:create): support options on db:create - #699

Closed
ALiangLiang wants to merge 5 commits into
sequelize:masterfrom
ALiangLiang:db-create-options
Closed

ALiangLiang wants to merge 5 commits into
sequelize:masterfrom
ALiangLiang:db-create-options

Conversation

@ALiangLiang

Copy link
Copy Markdown
Contributor

resolved #698
resolved #590
resolved #629

Use queryInterface.(create|drop)Database. So now we can:

  • Pass option to specify charset, collate... .
  • Use IF NOT EXISTS on database create and IF EXISTS on database drop. (postgresql not support IF NOT EXISTS on database)

But it's dependent on sequelize/sequelize@198cb52 . Not for release version now.

BTW. @sushantdhiman When is the release time of sequelize/master ? Is it for sequelize version 5?

@sushantdhiman

Copy link
Copy Markdown
Contributor

sequelize/master will be released as 5.0.0-beta.13 this weekend probably

@ALiangLiang

ALiangLiang commented Oct 16, 2018 •

Copy link
Copy Markdown
Contributor Author

O~k I see. So this PR cannot merge now right? It's required sequelize@5. 😕

Or I can make a version to use with sequelize@4. Just make a patch to support MySQL charset and collate.

const quoteIdentifier = sequelize.getQueryInterface().quoteIdentifier
await sequelize.query(`CREATE DATABASE ${quoteIdentifier(config.database)} CHARACTER SET ${quoteIdentifier(args.charset)} COLLATE ${quoteIdentifier(args.collate)`, {
  type: sequelize.QueryTypes.RAW
}).catch(e => helpers.view.error(e));

@sushantdhiman

Copy link
Copy Markdown
Contributor

We can switch to create/drop methods when sequelize@5 is used in cli, otherwise we can keep using old code for v4

@sushantdhiman

Copy link
Copy Markdown
Contributor

5.0.0-beta.13 was released with your changes for createDatabase / dropDatabase. Now we can use these commands when working with 5.0.0-beta.13 or above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants