Repository navigation
Closed
Labels
dependencyFor issues and PRs. Things that are related to one or more dependencies.dialect: postgresFor issues and PRs. Things that involve PostgreSQL (and do not involve all dialects).type: bugDEPRECATED: replace with the "bug" issue type
Description
What are you doing?
migration file: ./project/database/migrations/20190101060000-create-info.js
'use strict'
module.exports = {
up: (queryInterface, Sequelize) => {
try {
return queryInterface.createTable('Infos', {
InfoId: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
type: {
allowNull: false,
defaultValue: ['personal'],
type: Sequelize.ARRAY(
Sequelize.ENUM([
'current',
'permanent',
'home',
'office',
'personal'
])
)
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
})
} catch (err) {
console.log(err)
throw err
}
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Infos')
}
}The main issue is with the Sequelize.ARRAY(Sequelize.ENUM([...])) part.
What do you expect to happen?
The migration to be successful...
What is actually happening?
Sequelize CLI [Node: 8.11.4, CLI: 5.4.0, ORM: 5.0.0-beta.15]
Loaded configuration file "configs/sequelize-cli.config.js".
Using environment "development".
== 20190101060000-create-info: migrating =======
TypeError: Cannot read property 'getTableName' of undefined
at ARRAY._stringify (./project/node_modules/sequelize/lib/dialects/postgres/data-types.js:573:54)
at ARRAY.stringify (./project/node_modules/sequelize/lib/data-types.js:33:17)
at PostgresQueryGenerator.escape (./project/node_modules/sequelize/lib/dialects/abstract/query-generator.js:955:30)
at PostgresQueryGenerator.attributeToSQL (./project/node_modules/sequelize/lib/dialects/postgres/query-generator.js:502:31)
at PostgresQueryGenerator.attributesToSQL (./project/node_modules/sequelize/lib/dialects/postgres/query-generator.js:578:45)
at QueryInterface.createTable (./project/node_modules/sequelize/lib/query-interface.js:233:38)
at Object.up (./project/database/migrations/20190101060000-create-info.js:6:29)
at ./project/node_modules/umzug/lib/migration.js:130:33
at Generator.next (<anonymous>)
at step (./project/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at ./project/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
ERROR: Cannot read property 'getTableName' of undefined
Dialect: postgres
Dialect version: "pg": "^7.8.0", "pg-hstore": "^2.3.2",
Database version: 11.1
Sequelize version: 5.0.0-beta.15
Tested with latest release: 5.0.0-beta.15
Reacted by Jared Ramirez and Artyom Kolesen
Metadata
Metadata
Assignees
Labels
dependencyFor issues and PRs. Things that are related to one or more dependencies.dialect: postgresFor issues and PRs. Things that involve PostgreSQL (and do not involve all dialects).type: bugDEPRECATED: replace with the "bug" issue type
Activity
stale commentedon Apr 25, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
MunifTanjim commentedon Apr 25, 2019
👋🏼
nhattran998 commentedon Aug 5, 2019
Still not working, hope you can fix @papb
papb commentedon Aug 5, 2019
Is this solely an issue with migrations, or something similar can be reproduced without the CLI?
nhattran998 commentedon Aug 5, 2019
It's migrations!
papb commentedon Aug 5, 2019
@jetaimefrc Are you saying that running the
queryInterface.createTable()call outside the migrations environment works?nhattran998 commentedon Aug 5, 2019
I do migrate up to migrations table! Yes, I used queryInterface.createTable()
papb commentedon Aug 5, 2019
I discovered that this is not a Migrations issue. I opened a clean new issue to track this: #11285
LWanjiru commentedon Sep 21, 2023
Hope this helps. I was stuck too long trying to figure it out after I got major bugs on a project. Here's the link to how I solved it ==> #11285 (comment)