PG::DatatypeMismatch: ERROR: default for column "complete" cannot be cast automatically to type integer
I was told that the complete column cannot be automatically converted to an integer.
def up
change_column :habits, :complete, :integer, using: 'complete :: integer'
end
def down
change_column :habits, :complete, :boolean, default: false, null: false
end
end
I changed from boolean to integer type in change_column, but an error occurred because I tried to change to integer while default was false in the complte column.
So delete the false data in the complte column and rails db: migrate: reset
This is a safe solution
Recommended Posts