我正在yarn sequelize db:migrate使用 docker 中的 postgres 图像在数据库中创建表,并返回以下消息:
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
文件配置.sequelizerc:
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'),
};
在文件中创建表的代码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');
},
};
操作系统:Linux Focal Fossa 20.04 LTS
有谁知道可能的解决方案是什么?
湖上湖
相关分类