如何找到续集迁移文件?

时间:2017-02-28 04:46:20

标签: node.js sequelize.js sequelize-cli

通过sequilize-cli文件结构访问sequelize迁移文件有很多帖子。但是,如果我没有使用sequilize-cli,那么如何找到迁移文件?

1 个答案:

答案 0 :(得分:2)

好吧,为了使用迁移并运行它们,您需要使用 $depId = "SELECT * FROM departments WHERE departmentId = $department" $result = mysqli_query($connection,$depId);//$connection is database connection object while($row = mysqli_fetch_assoc($result)){ if($department == $row['departmentId']) { $fullname = $row['fullname']; $address = $row['address']; $barangay = $row['barangay']; $complainee = $row['complainee']; $subject = $row['subject']; $message = $row['message']; $query = "INSERT INTO complain (department,name,address,barangay,complainee,subject,message) VALUES('$department','$fullname','$address','$barangay','$complainee','$subject','$message')"; mysqli_query($connection,$query); } } ,您可以运行命令sequelize-cli,它将初始化使用cli所需的文件夹/文件。

但是,您可以通过使用自己的结构并创建名为sequelize init的文件来忽略该步骤,您可以在其中放置迁移/种子,例如我的如下所示:

.sequelizerc

因此,如果我运行const path = require('path') module.exports = { 'config': path.resolve('config', 'db.json'), 'migrations-path': path.resolve('db', 'migrate'), 'seeders-path': path.resolve('db', 'seeders') } ,cli将自动在db / migrate文件夹中查找迁移