0
數據庫PostgreSQL的PG :: InvalidDatetimeFormat:錯誤:類型日期無效的輸入語法:「」
我有以下遷移:
class AlterBirthdayInUsers < ActiveRecord::Migration[5.0]
def change
change_column :users, :birthday, 'date USING CAST(birthday AS date)', default: Date.today
end
end
遷移已啓動的錯誤:
rake stdout: == 20170201162913 AlterBirthdayInUsers: migrating =======================
-- change_column(:users, :birthday, "date USING CAST(birthday AS date)", {:default=>Sat, 18 Feb 2017})
rake stderr: rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::InvalidDatetimeFormat: ERROR: invalid input syntax for type date: ""
: ALTER TABLE "users" ALTER COLUMN "birthday" TYPE date USING CAST(birthday AS date)
date類型的遷移字段中的postgrees的正確點是什麼?
在此先感謝您的答覆。
嘗試改變'使用CAST(生日AS日期)'來'使用CAST(情況下,當生日=''然後null其他生日結束AS日期)' –
謝謝你,尊重 –