summaryrefslogtreecommitdiff
path: root/db/migrate/20210616134905_add_timestamp_to_schema_migration.rb
blob: 7086b20c48fb57d4594ef401582c78b0fc6c63ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

class AddTimestampToSchemaMigration < ActiveRecord::Migration[6.1]
  def up
    # Add a nullable column with default null first
    add_column :schema_migrations, :finished_at, :timestamptz

    # Change default to NOW() for new records
    change_column_default :schema_migrations, :finished_at, -> { 'NOW()' }
  end

  def down
    remove_column :schema_migrations, :finished_at
  end
end