Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not set charset and collate options on postgresql #623

Closed
QuentinFarizon opened this issue Oct 26, 2023 · 12 comments · Fixed by #624
Closed

Do not set charset and collate options on postgresql #623

QuentinFarizon opened this issue Oct 26, 2023 · 12 comments · Fixed by #624
Labels

Comments

@QuentinFarizon
Copy link
Contributor

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Sequelize v7.0.0-alpha.33 complains (rightly so), that collate and charset optinos are not supposed to be passed for postgres dialect. To my knowledge, this is only used for mysql

Here is the diff that solved my problem:

diff --git a/node_modules/umzug/lib/storages/SequelizeStorage.js b/node_modules/umzug/lib/storages/SequelizeStorage.js
index 1277063..469a6cc 100644
--- a/node_modules/umzug/lib/storages/SequelizeStorage.js
+++ b/node_modules/umzug/lib/storages/SequelizeStorage.js
@@ -90,8 +90,8 @@ class SequelizeStorage extends _Storage.default {
       tableName: this.tableName,
       schema: this.schema,
       timestamps: this.timestamps,
-      charset: 'utf8',
-      collate: 'utf8_unicode_ci'
+      charset: this.sequelize.dialect.name === 'mysql' ? 'utf8' : null,
+      collate: this.sequelize.dialect.name === 'mysql' ? 'utf8_unicode_ci' : null
     });
   }
   /**

This issue body was partially generated by patch-package.

@WikiRik
Copy link
Member

WikiRik commented Oct 26, 2023

See #612 for earlier discussion about this

@QuentinFarizon
Copy link
Contributor Author

@WikiRik What do you think of my solution ?

With something like :

const charsetableDialects = ['mysql', 'mariadb', 'snowflake']
(...)
charset: charsetableDialects.includes(this.sequelize.dialect.name) ? 'utf8' : null,
collate: charsetableDialects.includes(this.sequelize.dialect.name) ? 'utf8_unicode_ci' : null

@WikiRik
Copy link
Member

WikiRik commented Oct 26, 2023

That looks good

@QuentinFarizon
Copy link
Contributor Author

@WikiRik I've pushed a PR : #624

Copy link

github-actions bot commented Nov 4, 2023

Released in v3.4.0.

Copy link

github-actions bot commented Nov 4, 2023

Released in v3.4.0.

@qfarizon-qftech
Copy link

@WikiRik It would be great to update sequelize-cli to use this new version !

@WikiRik
Copy link
Member

WikiRik commented Apr 10, 2024

@qfarizon-qftech sequelize-cli is not meant tested with or updated for the v7 alphas and still uses umzug v2. The new CLI, which we started work on in the sequelize monorepo (and will be published as @sequelize/cli), will be using umzug v3 with this update.

@qfarizon-qftech
Copy link

@WikiRik Can I test @sequelize/cli as of today ?

@WikiRik
Copy link
Member

WikiRik commented Apr 10, 2024

@WikiRik Can I test @sequelize/cli as of today ?

It only has the seed generate and migration generate commands so it's not usable yet. (We're doing a full rewrite)

If @mmkal agrees you might be able to backport your change to umzug v2 and see how much of the old CLI works with the v7 alphas.

@qfarizon-qftech
Copy link

For now I have patched umzug@2 using patch-package.

@mmkal
Copy link
Contributor

mmkal commented Apr 10, 2024

If anyone would like to backport anything to v2.x I'm fine to review a pull request and publish, just open it against v2.x branch. I won't check it beyond just building and publishing though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants