cli icon indicating copy to clipboard operation
cli copied to clipboard

db: migrate creates table with plural name, while freezeTableName:true option specified

Open stonedraider opened this issue 6 years ago • 12 comments

What are you doing? I call db:migrate and it creates table with plural name, though I've specified freezeTableName: true option.

development: { dialect: "sqlite", storage:[hidden on purpose], operatorsAliases: Sequelize.Op, define: { freezeTableName: true }, query: { raw: true } // Always get raw result }, What do you expect to happen? I expect the name of created table to be singular while running db:migrate

What is actually happening? It creates a valid table , but with plural name. Instead of User it creates Users

Dialect: sqlite Dialect version: 3.1.13 Database version: 3.1.13 Sequelize version: 4.28.0 Tested with latest release: No

stonedraider avatar Dec 21 '17 10:12 stonedraider

modifying the migration script as suggested by hbgdPro (https://github.com/sequelize/sequelize/issues/8785) also isn't helpful, because the sequelize queries are still expecting pluralized tables, which means I will get SequelizeDatabaseError, because it will look for e.g. table buildings instead building in database.

stonedraider avatar Dec 21 '17 10:12 stonedraider

Same issue. I have set "define" : { "freezeTableName" : true, "timestamps" : false, "underscored": true } in config.json.

When I call db:migrate it create tables with plural names , timestanps , camelCase column ...

Dialect: mssql Dialect version driver: "SQL Server Native Client 11.0", Sequelize version: 4.33.0 Tested with latest release: yes

Sancho66 avatar Feb 21 '18 14:02 Sancho66

I got the same result. How to patch this ?

born010code avatar May 08 '18 11:05 born010code

Configuration should be read in https://github.com/sequelize/cli/blob/master/src/helpers/migration-helper.js#L8 and in https://github.com/sequelize/cli/blob/master/src/assets/migrations/create-table.js

hash avatar Jun 07 '18 11:06 hash

Still no answer on this issue? I have the same issue with Sequelize CLI [Node: 8.9.4, CLI: 5.4.0, ORM: 4.42.0]

massimosgrelli avatar Dec 21 '18 13:12 massimosgrelli

Any update/plan to fix this issue?

lunzai avatar Mar 26 '19 09:03 lunzai

Not fixed yet, in the other hand I rambled about if this is an issue or not here https://github.com/sequelize/sequelize/issues/7566#issuecomment-590027672

brunofunnie avatar Feb 23 '20 04:02 brunofunnie

In models/index.js, add the line config.freezeTableName = true;

TheDirigible avatar Apr 26 '20 16:04 TheDirigible

Does anyone fix this?

AbdallahAmmar96 avatar May 01 '20 04:05 AbdallahAmmar96

In models/index.js, add the line config.freezeTableName = true;

models/index.js is not used when you use sequelize model:generate try this by deleting the index file and try to add a new model with the CLI tool

AbdallahAmmar96 avatar May 01 '20 04:05 AbdallahAmmar96

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 03 '20 03:07 stale[bot]

any updates?

MkDierz avatar Apr 17 '23 18:04 MkDierz