Rails & Postgres: Migration to change_colomn gives error “cannot be cast to type timestamp without time zone”

前端 未结 2 1696
轻奢々
轻奢々 2021-02-19 20:09

A Rails migration to turn a \"deleted_at\" time column to a datetime column failed. Any ideas on how to solve this? It\'s a fresh install of Postgres if that is relevant.

<
2条回答
  •  佛祖请我去吃肉
    2021-02-19 20:57

    In Rails this would look something like

    class ChangeStatusUpdatedAtToDateTime < ActiveRecord::Migration
      def up
        remove_column :bookings, :status_updated_at
        add_column :bookings, :status_updated_at, :datetime
      end
    
      def down
        remove_column :bookings, :status_updated_at
        add_column :bookings, :status_updated_at, :time
      end
    end
    

提交回复
热议问题