1
我嘗試將默認列值從false更改爲true。但是當我運行rake db:migrate VERSION=904984092840298
時,出現以下錯誤。使用遷移更改表列的默認值
StandardError: An error has occurred, this and all later migrations canceled:
PG::InvalidTextRepresentation: ERROR: invalid input syntax for type boolean: "---
:from: false
:to: true
"
: ALTER TABLE "plussites" ALTER COLUMN "hide_season_selector" SET DEFAULT '---
:from: false
:to: true
'
遷移
class ChangeDefaultvalueForHideSeasonSelector < ActiveRecord::Migration
def change
change_column_default :plussites, :hide_season_selector, from: false, to: true
end
end
非常感謝!這是工作! :) – Lory
@Lory,但奇怪的是,你的原始代碼沒有,因爲它看起來正確根據文檔 –
這對我來說也很奇怪,因爲我完全按照文檔編寫它。 – Lory