discourse/db/migrate/20200417183143_add_created_at_to_badge_user.rb
2023-01-09 11:59:41 +00:00

13 lines
420 B
Ruby

# frozen_string_literal: true
class AddCreatedAtToBadgeUser < ActiveRecord::Migration[6.0]
def up
add_column :user_badges, :created_at, :datetime, null: true
execute "UPDATE user_badges SET created_at = granted_at WHERE created_at IS NULL"
change_column :user_badges, :created_at, :datetime, null: false, default: "current_timestamp"
end
def down
remove_column :user_badges, :created_at
end
end