Skip to content

Instantly share code, notes, and snippets.

@narath
Created September 27, 2021 20:11
Show Gist options
  • Save narath/90170c0bb402201462e0116b36f509d0 to your computer and use it in GitHub Desktop.
Save narath/90170c0bb402201462e0116b36f509d0 to your computer and use it in GitHub Desktop.
Rails Migration to add a default value to created_at and updated_at so COPY_FROM can work
class ChangeRawDiagnosesCreatedAtAndUpdatedAt < ActiveRecord::Migration[5.1]
def change
change_column_default :raw_diagnoses, :created_at, from: nil, to: -> { 'CURRENT_TIMESTAMP' }
change_column_default :raw_diagnoses, :updated_at, from: nil, to: -> { 'CURRENT_TIMESTAMP' }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment