I run this command: $ sequelize model:create --name "Person", but generate the name "People"
20190121082004-create-person.js
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('People', {
Even if i change People to Person, i got some error when i was run: $ sequelize db:migrate
Unhandled rejection SequelizeDatabaseError: Table 'demodb.people' doesn't exist
Is there anyone got the same with me ?
Greetings.
$ sequelize db:migrate:undo to undo the migration before running it again.Explanation:
db:migrate:undo to undo the migration.db:migrate:undo will not work.The model at models/person.js is meant to be used for an ORM environment. Please also consider updating it properly.
Please also consider reading the tutorial docs fully.
Thanks for reply. @KinoshitaShimizu
I found that when i create a name man, will change to men, so i think that is some kind of rule,
but i still can't found it in the docs.
@tsurumure
I think it's due to the freezeTableName flag from Configuration, it reads as follows:
You can also influence the way Sequelize handles your column names:
const Bar = sequelize.define('bar', { /* bla */ }, { ... // disable the modification of table names; By default, sequelize will automatically // transform all passed model names (first parameter of define) into plural. // if you don't want that, set the following freezeTableName: true,
By default, the value is false (Sequelize will pluralize table names).
1) Try setting freezeTableName: false on your model/person.js.
I don't know the CLI command. Will look up later if I have a chance.
Great help, thanks!
For cli, in models/index.js
config.freezeTableName = true;
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.
Most helpful comment
@tsurumure
I think it's due to the
freezeTableNameflag from Configuration, it reads as follows:By default, the value is false (Sequelize will pluralize table names).
1) Try setting
freezeTableName: falseon yourmodel/person.js.I don't know the CLI command. Will look up later if I have a chance.