gpt4 book ai didi

sql-server - Sequelize-cli 不执行任何操作

转载 作者:太空宇宙 更新时间:2023-11-04 02:23:04 24 4
gpt4 key购买 nike

我正在尝试使用sequelize和sequelize-cli通过迁移机制来创建数据库架构更改(MSSQL)。但什么也没有发生 - 看起来它在迁移文件夹中没有找到任何迁移文件。

我在新文件夹中执行了以下操作来创建测试项目:

npm init
[ added relevant packages: sequelize, sequelize-cli, tedious ]
sequelize init
[ here I added the connection information, all to a blank database on Azure SQL ]
sequelize init:models
sequelize init:migrations
sequelize migration:create

我将以下内容添加到创建的迁移文件中:

'use strict';
module.exports = {
up: function (queryInterface, Sequelize) {
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
},
down: function (queryInterface, Sequelize) {
return queryInterface.dropTable('users');
}
};

这基本上只是根据最后一个sequelize命令创建的模板。

现在我希望在运行迁移命令时创建一个新表:

sequelize db:migrate

但我得到的只是这个:

Sequelize [Node: 0.12.2, CLI: 1.7.4, ORM: 3.5.1]
Loaded configuration file "config/config.json".
Using environment "development".
Using gulpfile /usr/local/lib/node_modules/sequelize-cli/lib/gulpfile.js
Finished 'db:migrate' after 161 ms

这意味着它没有找到任何迁移文件。数据库中没有出现任何表,也没有创建sequelizeMeta表。

出了什么问题?

最佳答案

您可以尝试在根目录中创建 .sequelizerc 文件以将其指向正确的迁移文件夹:

var path = require('path');

module.exports = {
'config': path.resolve('path/to/folder', 'config/config.json'),
'migrations-path': path.resolve('path/to/folder', 'migrations'),
'models-path': path.resolve('path/to/folder, 'models')
}

创建文件后运行sequelize init

关于sql-server - Sequelize-cli 不执行任何操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32072674/

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