我正在运行sequelize-cli db:migrate
来初始化迁移,但发生了这种情况
Sequelize CLI \[Node: 19.6.1, CLI: 6.6.0, ORM: 6.28.1\]
Loaded configuration file "config\\config.js".
== 20230221223939-aluno: migrating =======
ERROR: Cannot read properties of undefined (reading 'type')
这是我的config.js文件:
module.exports = {
dialect: 'postgres',
host: 'localhost',
username: 'postgres',
password: '123456',
database: 'projetoBiblioteca',
define: {
timestamps: true,
},
};
这是我的迁移文件:
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('aluno', {
matricula: {
type: Sequelize.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: false,
},
nome: {
type: Sequelize.STRING,
allowNull: false,
},
curso: {
type: Sequelize.STRING,
allowNull: false,
},
ano: {
type: Sequelize.INTEGER,
allowNull: false,
},
createdAt: {
type: Sequelize.DATA,
},
updatedAt: {
type: Sequelize.DATA,
},
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('aluno');
}
};
这是我的package.json文件:
{
"name": "projetobiblioteca",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2",
"pg": "^8.9.0",
"pg-hstore": "^2.3.4",
"sequelize": "^6.28.1"
},
"devDependencies": {
"nodemon": "^2.0.20"
}
}
我已经尝试了一些决议从其他职位,但它没有工作。有人能帮我这个吗?(有些话在这些代码是葡萄牙语,不要担心)
1条答案
按热度按时间ovfsdjhp1#
尝试按迁移配置文档所示的环境划分配置:
配置/配置json
您也可以只使用
return queryInterface
而不是await queryInterface
。