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
{{ message }}
Repository navigation
Bug? db:create cannot set default charset with connection information. #590
I avoid this problem by querying ALTER DATABASE from a migration file like this:
/db/migrations/00000-fix-db-charset.js
module.exports={up: (queryInterface,Sequelize)=>{returnqueryInterface.sequelize.query(`ALTER DATABASE ${queryInterface.sequelize.config.database} CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;`)},down: (queryInterface,Sequelize)=>{}}
With naming the file like 00000-xxxxx.js, we can throw the query just before running other migrations.
Reacted by Tizian Adam, Movsun, Telokis, Antoine Zanardi, Artem Dontsov, Michael, Kacper Perzankowski, Ali Foroughi, Dongsen, Indospace.io and 13 more
Reacted by Jungdo Lee, roko_cupic, Rik van der Kemp, Konrad Le, Rildomar Lucena and Geovani
I avoid this problem by querying ALTER DATABASE from a migration file like this:
/db/migrations/00000-fix-db-charset.js
module.exports={up: (queryInterface,Sequelize)=>{returnqueryInterface.sequelize.query(`ALTER DATABASE ${queryInterface.sequelize.config.database} CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;`)},down: (queryInterface,Sequelize)=>{}}
With naming the file like 00000-xxxxx.js, we can throw the query just before running other migrations.
This solution worked for me. Is there any update on this by sequelize team?
Reacted by Rik van der Kemp, Jakub Gałecki, Ken Elliott, Klaus Breyer, Randy J. Ray and Artyom Tsurkan
I avoid this problem by querying ALTER DATABASE from a migration file like this:
/db/migrations/00000-fix-db-charset.js
module.exports={up: (queryInterface,Sequelize)=>{returnqueryInterface.sequelize.query(`ALTER DATABASE ${queryInterface.sequelize.config.database} CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;`)},down: (queryInterface,Sequelize)=>{}}
With naming the file like 00000-xxxxx.js, we can throw the query just before running other migrations.
It works for me like that, but if someone is still experiencing the same issue, I needed to use back quotes around database name `${queryInterface.sequelize.config.database}` or it throws a syntax error.
Activity
fix(db:create/drop): Add charset parameter in query string (sequelize…
chris-fung commentedon Jan 10, 2018
Met the same problem with yours. Just need to modify the charset and collate by myself after creating db
galki commentedon Feb 23, 2018
according to this using
defineinstead ofdialectOptionsworks when creating a sequelize connection, but it doesn't work when using cli todb:createi also tried to set the charset/collation in the model migration like the docs say by adding the third arg to:
and that results in error:
Sequelize CLI version: 4.0.0
kwbtdisk commentedon Mar 2, 2018
I avoid this problem by querying
ALTER DATABASEfrom a migration file like this:/db/migrations/00000-fix-db-charset.jsWith naming the file like 00000-xxxxx.js, we can throw the query just before running other migrations.
jeanpchr commentedon Apr 19, 2018
+1
perzanko commentedon Sep 3, 2018
Problem occured for me as well.
ALiangLiang commentedon Nov 4, 2018
@Huangyanyang
No, but you can specify with args.
sequelize db:create --charset <CHARSET>vishwasraj commentedon Dec 23, 2018
It would have been good. If it was taken from the config file.
rcupic commentedon Apr 2, 2019
This solution worked for me. Is there any update on this by sequelize team?
Fix Sequelize DB charset encoding
Fix Sequelize DB charset encoding
abhijeet029 commentedon Apr 29, 2020
add { charset: 'utf8' } in your migration file after the data column object
rem711 commentedon Apr 28, 2021
It works for me like that, but if someone is still experiencing the same issue, I needed to use back quotes around database name `${queryInterface.sequelize.config.database}` or it throws a syntax error.