簡體   English   中英

為什么這種遷移不可逆轉? (change_table,rename,text)

[英]Why is this migration irreversible? (change_table, rename, text)

我認為這是一個非常簡單的遷移。 出於某種原因,當我嘗試db:rollbackdb:migrate:redo時,我收到了IrreversibleMigration錯誤。

遷移順利進行,但我寧願保持可逆。 我無法弄清楚為什么它不像書面那樣。 有任何想法嗎?

這是遷移:

class AddWhyHypAndWhyHypeToStatements < ActiveRecord::Migration
  def change
    change_table :statements do |t|
      t.rename :description, :why_hypocritical
      t.text   :why_hypothetical
    end
  end
end

如果重要,“description”列是文本列。 我正在使用Rails 3.1 / Ruby 1.9.2 / PostgreSQL。 謝謝你的幫助。

看起來Rails在恢復change_table方法時遇到了麻煩。 嘗試這樣做:

class AddWhyHypAndWhyHypeToStatements < ActiveRecord::Migration
  def change
    rename_column :statements, :description, :why_hypocritical
    add_column :statements, :why_hypothetical, :text
  end
end

您可以在文檔Rails指南中看到可以反轉的命令列表。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM