gpt4 book ai didi

ruby-on-rails - heroku 运行 rake db :migrate reverts migrations

转载 作者:数据小太阳 更新时间:2023-10-29 08:59:46 26 4
gpt4 key购买 nike

我在 heroku 上运行我的应用程序,使用 heroku pg 堆栈,当我运行 db:migrate 时,它​​会恢复我之前的迁移而不是继续。

rake db:version 显示当前迁移

Current version: 20160516172744

rake db:migrate:status 显示所有迁移

......(more above all up)
up 20160512175053 Create spree roles permissions.spree admin roles and access
up 20160512175054 Add editable is default and index on editable is default and name to spree roles.spree admin roles and access
up 20160513135317 Add indexes for speed
up 20160513140704 Add filter search params to spree product
up 20160516172744 Add tsvector colums to spree products

但是当我点击 heroku run rake db:migrate 时,这是输出:

Migrating to AddTsvectorColumsToSpreeProducts (20160516172744)
== 20160516172744 AddTsvectorColumsToSpreeProducts: reverting =================
-- execute(" DROP FUNCTION IF EXISTS spree_products_tsv_trigger() CASCADE;\n")
-> 0.0031s
-- remove_index(:spree_products, :tsv)
-> 0.0058s
-- remove_column(:spree_products, :tsv)
-> 0.0025s
== 20160516172744 AddTsvectorColumsToSpreeProducts: reverted (0.0122s) ========

Migrating to AddFilterSearchParamsToSpreeProduct (20160513140704)
== 20160513140704 AddFilterSearchParamsToSpreeProduct: reverting ==============
-- remove_column(:spree_products, :designer_id)
-> 0.0062s
-- remove_column(:spree_products, :main_taxon_id)
-> 0.0024s
-- remove_column(:spree_products, :colour_id)
-> 0.0025s
-- remove_column(:spree_products, :size_id)
-> 0.0045s
-- remove_column(:spree_products, :condition_id)
-> 0.0023s
-- remove_column(:spree_products, :on_site)
-> 0.0023s
-- remove_column(:spree_products, :sgd_price)
-> 0.0025s
-- remove_column(:spree_products, :search_designer)
-> 0.0022s
-- remove_column(:spree_products, :search_category)
-> 0.0021s
-- remove_column(:spree_products, :search_sku)
-> 0.0022s
== 20160513140704 AddFilterSearchParamsToSpreeProduct: reverted (0.0341s) =====
.....(cont.)

有什么想法吗?

-丹

最佳答案

rake db:migrate 将在没有任何参数的情况下,只迁移 up 到最新版本。如果您看到它向下迁移,您很可能将 VERSION 环境变量设置为某个值(请参阅 the docs 以了解该变量的工作原理),并且 Rails 正在尝试迁移到该版本.

在您的情况下,根据评论,您似乎在您的环境中设置了 VERSION=v3。 Rails 可能会将 v3 转换为 0 并尝试向下迁移所有迁移。

关于ruby-on-rails - heroku 运行 rake db :migrate reverts migrations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39238458/

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