0

エラーが発生します

PGError: ERROR:  type modifier is not allowed for type "text"
LINE 1: ...ng(255), "desc" character varying(255), "content" text(255),...

heroku run rake db:resetを実行すると

postgresqlには「text」の無制限のタイプが必要であり、最新の移行ファイルには...

class ChangeLessonsTable < ActiveRecord::Migration
    def change
        change_table :lessons do |t|
            t.change        :content, :text, :limit => nil
        end
    end
end

それでもエラーが発生し続けます。なぜ何かアイデア?rake db:reset、rake db:migrate、およびgit pushを実行して、ローカルデータベースが変更されたことを確認しました。次に、githerokupushとherokurunrake db:resetを実行しましたが、エラーが発生し続けます。私は何かが足りないのですか?ありがとう

4

1 に答える 1

4

:limitあなたは完全にオフにすることができるはずです:

class ChangeLessonsTable < ActiveRecord::Migration
    def change
        change_table :lessons do |t|
            t.change :content, :text
        end
    end
end

それでもうまくいかない場合は、上下のアクションを別々に試すことができます。

def up
    change_column :lessons, :content, :text
end
def down
    change_column :lessons, :content, :string
end

余談ですが、PostgreSQL をターゲットにしている場合は、 (AKA ) 列の型:textを忘れて使用する必要があります。PostgreSQL はそれらを内部的にすべて同じように扱います。varchar/ を気にする必要があるのは、データの整合性のために文字列サイズに特定の上限が必要な場合だけです。:stringvarchar:string

于 2012-04-18T04:33:04.073 に答える