为了账号安全,请及时绑定邮箱和手机立即绑定

使用 db:migrate 创建表时,Sequelize CLI 迁移错误“无法读取未定义的属性

使用 db:migrate 创建表时,Sequelize CLI 迁移错误“无法读取未定义的属性

慕尼黑5688855 2022-10-21 10:53:37
我正在yarn sequelize db:migrate使用 docker 中的 postgres 图像在数据库中创建表,并返回以下消息:mateus @ fariasmateuss: ~ / Projects / gobarber / server $ yarn sequelize db: migrateyarn run v1.22.4$ /home/mateus/Projects/gobarber/server/node_modules/.bin/sequelize db: migrateSequelize 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 undefinederror 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有谁知道可能的解决方案是什么?
查看完整描述

1 回答

?
湖上湖

TA贡献2003条经验 获得超2个赞

错误似乎是一个错字,typefor Sequelize.DATAvs Sequelize.DATE.

以下是有效的数据类型。

https://sequelize.org/v5/manual/data-types.html


查看完整回答
反对 回复 2022-10-21
  • 1 回答
  • 0 关注
  • 152 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号