我需要在rails中更改列类型从时间到日期时间。我无法更改列类型。它显示此错误
"rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::DatatypeMismatch: ERROR: column "fun_from" cannot be cast automatically to type timestamp without time zone
HINT: Specify a USING expression to perform the conversion.
: ALTER TABLE "general_infos" ALTER COLUMN "fun_from" TYPE timestamp/home/PCA/db/migrate/20150730102811_change_data_type_in_general_infos.rb:3:in `change'
ActiveRecord::StatementInvalid: PG::DatatypeMismatch: ERROR: column "fun_from" cannot be cast automatically to type timestamp without time zone
HINT: Specify a USING expression to perform the conversion.
: ALTER TABLE "general_infos" ALTER COLUMN "fun_from" TYPE timestamp
/home/PCA/db/migrate/20150730102811_change_data_type_in_general_infos.rb:3:in `change'
PG::DatatypeMismatch: ERROR: column "fun_from" cannot be cast automatically to type timestamp without time zone
HINT: Specify a USING expression to perform the conversion.
/home/PCA/db/migrate/20150730102811_change_data_type_in_general_infos.rb:3:in `change'"
我试过以下格式,
change_column(:table_name, :column_name, :datetime )
并尝试以下格式
change_column :table_name, :column_name, 'datetime USING CAST(column_name AS datetime)'
psql版本 - 9.4.4&任何人都给我解决方案。