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