简体   繁体   English

如果已经运行了来自其他分支的更高版本的迁移,那么如何在Heroku上运行从Git分支进行的迁移?

[英]How does a migration from a Git branch get run on Heroku if a later migration from a different branch has already been run?

Say I create a branch ( new_branch ). 假设我创建了一个分支( new_branch )。 In that branch, a migration ( migration_1 ) is created. 在该分支中,创建了一个迁移( migration_1 )。

Later, I switch back to master . 后来,我切换回master I then create a migration ( migration_2 ), push to Heroku, and run migrations on Heroku. 然后,我创建一个迁移( migration_2 ),推送到Heroku,然后在Heroku上运行迁移。

Later still, I merge new_branch into master , and then push master to Heroku. 稍后,我将new_branch合并到master ,然后将master推送到Heroku。

When I try to run migrations on Heroku, won't migration_1 be skipped over and not run, because it was created before migration_2 , which has already been run? 当我尝试在Heroku上运行迁移时,不会跳过migration_1而不运行它,因为它是在migration_2之前创建的,而该migration_2已经运行了吗?

Each migration has a migration timestamp attached. 每个迁移都附带一个迁移时间戳。 The list of successfully applied migrations is stored in a schema table inside your Rails application. 成功应用的迁移列表存储在Rails应用程序内的模式表中。

When you run migration_2 , this entry is added to the database. 当您运行migration_2 ,此条目将添加到数据库中。 When migration_1 is merged, Rails will detect the change has not been applied yet because the entry is missing in the schema table, and will run it. 合并migration_1 ,Rails将检测到尚未应用更改,因为架构表中缺少该条目,并将运行该更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM