gpt4 book ai didi

javascript - 续集数据库 :migrate hanging

转载 作者:行者123 更新时间:2023-11-30 06:16:19 25 4
gpt4 key购买 nike

我正在尝试让我的模型迁移到我正在使用的 postgress 数据库,该数据库在本地托管,我确认它已正常运行。

当我运行 sequelize db:migrate 时,它说

Loaded configuration file "config\config.json"
Using environment "development"

然后什么都没有,我不能输入控制台或任何东西,它只是坐在那里,直到我按 ctrl+C 退出它

我尝试恢复我对模型和迁移文件所做的所有更改,以防出现问题但没有帮助。

编辑:我还尝试通过 npm 重新安装 sequelize-cli,但也没有解决问题

这是问题所在的模型和迁移代码

型号:

'use strict';
module.exports = (sequelize, DataTypes) => {
const Contract = sequelize.define('Contract', {
buyout: DataTypes.DOUBLE,
collateral: DataTypes.DOUBLE,
contract_id: {type:DataTypes.INTEGER,allowNull: false,},
date_expired: {type:DataTypes.DATE,allowNull: false,},
date_issued: {type:DataTypes.DATE,allowNull: false,},
days_to_complete: DataTypes.INTEGER,
end_location_id: DataTypes.BIGINT,
for_corporation: DataTypes.BOOLEAN,
issuer_corporation_id: {type:DataTypes.INTEGER,allowNull: false,},
issuer_id: {type:DataTypes.INTEGER,allowNull: false,},
price: DataTypes.DOUBLE,
reward: DataTypes.DOUBLE,
start_location_id: DataTypes.BIGINT,
title: DataTypes.STRING,
type: {type:DataTypes.STRING,allowNull: false,},
volume: DataTypes.DOUBLE
});
Contract.associate = (models) => {
Contract.hasMany(models.ContractItem,{
foreignKey: 'contract_id'
});
};
return Contract;
};

迁移

'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Contracts', {
buyout: {
type: Sequelize.DOUBLE
},
collateral: {
type: Sequelize.DOUBLE
},
contract_id: {
allowNull: false,
primaryKey: true,
type: Sequelize.INTEGER
},
date_expired: {
allowNull: false,
type: Sequelize.DATE
},
date_issued: {
allowNull: false,
type: Sequelize.DATE
},
days_to_complete: {
type: Sequelize.INTEGER
},
end_location_id: {
type: Sequelize.BIGINT
},
for_corporation: {
type: Sequelize.BOOLEAN
},
issuer_corporation_id: {
allowNull: false,
type: Sequelize.INTEGER
},
issuer_id: {
allowNull: false,
type: Sequelize.INTEGER
},
price: {
type: Sequelize.DOUBLE
},
reward: {
type: Sequelize.DOUBLE
},
start_location_id: {
type: Sequelize.BIGINT
},
title: {
type: Sequelize.STRING
},
type: {
allowNull: false,
type: Sequelize.STRING
},
volume: {
type: Sequelize.DOUBLE
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('Contracts');
}
};

最佳答案

我们最近遇到了同样的问题,解决方法是在 config.json 的环境配置中添加以下选项:

dialectOptions: {
ssl: true
}

当 sequelize cli 尝试验证 SequelizeMeta 表的模式时,它会运行一系列查询 - 其中一个在没有上述选项的情况下运行约半小时后超时。

注意:我们的第一次迁移运行仍在运行,因为它正在创建表,因此跳过了验证。

关于javascript - 续集数据库 :migrate hanging,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55937298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com