hackatime/db/migrate/20240320000002_switch_admin_at_to_is_admin.rb
Mahad Kalam 606bdaed01
Clean up migrations + schema.rb (#1055)
* Drop unused heartbeat lookup tables and their FK columns

Remove 8 abandoned normalization tables (heartbeat_branches,
heartbeat_categories, heartbeat_editors, heartbeat_languages,
heartbeat_machines, heartbeat_operating_systems, heartbeat_projects,
heartbeat_user_agents) and their corresponding foreign key columns
from the heartbeats table. None had models, associations, or any
application code referencing them.

* Remove migrations cancelling each other out
2026-03-11 16:52:35 +00:00

11 lines
330 B
Ruby

class SwitchAdminAtToIsAdmin < ActiveRecord::Migration[8.1]
def change
add_column :users, :is_admin, :boolean, default: false, null: false
# Copy data from admin_at to is_admin
User.reset_column_information
User.where.not(admin_at: nil).update_all(is_admin: true)
remove_column :users, :admin_at
end
end