I’m running yarn sequelize db:migrate
to create the table in the database using a postgres image in the docker and returns the following message:
mateus @ fariasmateuss: ~ / Projects / gobarber / server $ yarn sequelize db: migrate yarn run v1.22.4 $ /home/mateus/Projects/gobarber/server/node_modules/.bin/sequelize db: migrate Sequelize CLI [Node: 12.17.0, CLI: 6.0.0, ORM: 6.2.0] Loaded configuration file "src / config / database.js". == 20200627041347-create-users: migrating ======= ERROR: Cannot read property 'type' of undefined error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command
Configuration of the .sequelizerc
file:
const {resolve} = require ('path'); module.exports = { config: resolves (__ dirname, 'src', 'config', 'database.js'), 'models-path': resolves (__ dirname, 'src', 'app', 'models'), 'migrations-path': resolves (__ dirname, 'src', 'database', 'migrations'), 'seeders-path': resolves (__ dirname, 'src', 'database', 'seeds'), };
Code to create the table in the file migrations.js
:
module.exports = { up: (queryInterface, Sequelize) => { return queryInterface.createTable ('users', { id: { type: Sequelize.INTEGER, allowNull: false, autoIncrement: true, primaryKey: true, }, name: { type: Sequelize.STRING, allowNull: false, }, email: { type: Sequelize.STRING, allowNull: false, unique: true, }, password_hash: { type: Sequelize.STRING, allowNull: false, }, provider: { type: Sequelize.BOOLEAN, defaultValues: false, allowNull: false, }, created_at: { type: Sequelize.DATA, allowNull: false, }, updated_at: { type: Sequelize.DATA, allowNull: false, }, }); }, down: (queryInterface) => { return queryInterface.dropTable ('users'); }, };
OS: Linux Focal Fossa 20.04 LTS
Would anyone know what the possible solution would be?
Advertisement
Answer
Error seems to be a typo, the type
for Sequelize.DATA
vs Sequelize.DATE
.
Here are the valid data types.