Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kbaum/c6102c1bab4a22e70f3500edeb73fb56 to your computer and use it in GitHub Desktop.
Save kbaum/c6102c1bab4a22e70f3500edeb73fb56 to your computer and use it in GitHub Desktop.
class RenameClientCompanyToAccount < ActiveRecord::Migration
def change
safety_assured do
reversible do |dir|
dir.down { update_view :lease_connections, version: 6, revert_to_version: 7 }
end
#if table_exists?(:admin_add_user_to_property_requests) && column_exists?(:admin_add_user_to_property_requests, :client_company_id)
rename_column :admin_add_user_to_property_requests, :client_company_id, :account_id
#end
#if table_exists?(:admin_move_to_another_client_company_request_office_parks) && column_exists?(:admin_move_to_another_client_company_request_office_parks, :move_to_another_client_company_request_id)
rename_column :admin_move_to_another_client_company_request_office_parks, :move_to_another_client_company_request_id, :move_to_another_account_request_id
#end
#if table_exists?(:admin_move_to_another_client_company_request_office_parks)
rename_table :admin_move_to_another_client_company_request_office_parks, :admin_move_to_another_account_request_office_parks
#end
#if table_exists?(:admin_move_to_another_client_company_request_properties) && column_exists?(:admin_move_to_another_client_company_request_properties, :move_to_another_client_company_request_id)
rename_column :admin_move_to_another_client_company_request_properties, :move_to_another_client_company_request_id, :move_to_another_account_request_id
#end
#if table_exists?(:admin_move_to_another_client_company_request_properties)
rename_table :admin_move_to_another_client_company_request_properties, :admin_move_to_another_account_request_properties
#end
#if table_exists?(:admin_move_to_another_client_company_requests) && column_exists?(:admin_move_to_another_client_company_requests, :old_client_company_id)
rename_column :admin_move_to_another_client_company_requests, :old_client_company_id, :old_account_id
#end
#if table_exists?(:admin_move_to_another_client_company_requests) && column_exists?(:admin_move_to_another_client_company_requests, :new_client_company_id)
rename_column :admin_move_to_another_client_company_requests, :new_client_company_id, :new_account_id
#end
#if table_exists?(:admin_move_to_another_client_company_requests) && column_exists?(:admin_move_to_another_client_company_requests, :skip_users_on_destination_client_company_validation)
rename_column :admin_move_to_another_client_company_requests, :skip_users_on_destination_client_company_validation, :skip_users_on_destination_account_validation
#end
#if table_exists?(:admin_move_to_another_client_company_requests)
rename_table :admin_move_to_another_client_company_requests, :admin_move_to_another_account_requests
#end
#if table_exists?(:audit_events) && column_exists?(:audit_events, :client_company_id)
rename_column :audit_events, :client_company_id, :account_id
#end
#if table_exists?(:city_markets) && column_exists?(:city_markets, :client_company_id)
rename_column :city_markets, :client_company_id, :account_id
#end
#if table_exists?(:deal_api_requests) && column_exists?(:deal_api_requests, :client_company_id)
rename_column :deal_api_requests, :client_company_id, :account_id
#end
#if table_exists?(:ilevel_entities) && column_exists?(:ilevel_entities, :client_company_id)
rename_column :ilevel_entities, :client_company_id, :account_id
#end
#if table_exists?(:ilevel_investments) && column_exists?(:ilevel_investments, :client_company_id)
rename_column :ilevel_investments, :client_company_id, :account_id
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :client_company_create)
rename_column :internal_roles, :client_company_create, :account_create
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :client_company_edit)
rename_column :internal_roles, :client_company_edit, :account_edit
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :client_company_read)
rename_column :internal_roles, :client_company_read, :account_read
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :client_company_update)
rename_column :internal_roles, :client_company_update, :account_update
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :client_company_delete)
rename_column :internal_roles, :client_company_delete, :account_delete
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :client_company_user_read)
rename_column :internal_roles, :client_company_user_read, :account_user_read
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :client_company_user_edit)
rename_column :internal_roles, :client_company_user_edit, :account_user_edit
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :can_move_to_another_client_company_create)
rename_column :internal_roles, :can_move_to_another_client_company_create, :can_move_to_another_account_create
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :can_move_to_another_client_company_read)
rename_column :internal_roles, :can_move_to_another_client_company_read, :can_move_to_another_account_read
#end
#if table_exists?(:internal_roles) && column_exists?(:internal_roles, :can_edit_client_company_onboarding_in_progress)
rename_column :internal_roles, :can_edit_client_company_onboarding_in_progress, :can_edit_account_onboarding_in_progress
#end
#if table_exists?(:portfolio_exports) && column_exists?(:portfolio_exports, :client_company_id)
rename_column :portfolio_exports, :client_company_id, :account_id
#end
#if table_exists?(:portfolio_imports) && column_exists?(:portfolio_imports, :client_company_id)
rename_column :portfolio_imports, :client_company_id, :account_id
#end
#if table_exists?(:query_audits) && column_exists?(:query_audits, :client_company_id)
rename_column :query_audits, :client_company_id, :account_id
#end
#if table_exists?(:trm_tenant_possible_dupes) && column_exists?(:trm_tenant_possible_dupes, :client_company_id)
rename_column :trm_tenant_possible_dupes, :client_company_id, :account_id
#end
#if table_exists?(:trm_tenant_dedupe_audits) && column_exists?(:trm_tenant_dedupe_audits, :client_company_id)
rename_column :trm_tenant_dedupe_audits, :client_company_id, :account_id
#end
#if table_exists?(:activity_log_iterations) && column_exists?(:activity_log_iterations, :client_company_id)
rename_column :activity_log_iterations, :client_company_id, :account_id
#end
#if table_exists?(:client_company_users) && column_exists?(:client_company_users, :client_company_id)
rename_column :client_company_users, :client_company_id, :account_id
#end
#if table_exists?(:client_company_users)
rename_table :client_company_users, :account_users
#end
#if table_exists?(:approval_settings) && column_exists?(:approval_settings, :client_company_id)
rename_column :approval_settings, :client_company_id, :account_id
#end
#if table_exists?(:approval_property_groups) && column_exists?(:approval_property_groups, :client_company_id)
rename_column :approval_property_groups, :client_company_id, :account_id
#end
#if table_exists?(:tenant_programs) && column_exists?(:tenant_programs, :client_company_id)
rename_column :tenant_programs, :client_company_id, :account_id
#end
#if table_exists?(:submarkets) && column_exists?(:submarkets, :client_company_id)
rename_column :submarkets, :client_company_id, :account_id
#end
#if table_exists?(:asset_roles) && column_exists?(:asset_roles, :client_company_id)
rename_column :asset_roles, :client_company_id, :account_id
#end
#if table_exists?(:groups) && column_exists?(:groups, :client_company_id)
rename_column :groups, :client_company_id, :account_id
#end
#if table_exists?(:properties) && column_exists?(:properties, :client_company_id)
rename_column :properties, :client_company_id, :account_id
#end
#if table_exists?(:leases) && column_exists?(:leases, :client_company_id)
rename_column :leases, :client_company_id, :account_id
#end
#if table_exists?(:office_parks) && column_exists?(:office_parks, :client_company_id)
rename_column :office_parks, :client_company_id, :account_id
#end
#if table_exists?(:activity_logs) && column_exists?(:activity_logs, :client_company_id)
rename_column :activity_logs, :client_company_id, :account_id
#end
#if table_exists?(:client_companies)
rename_table :client_companies, :accounts
#end
#if table_exists?(:tenants) && column_exists?(:tenants, :client_company_id)
rename_column :tenants, :client_company_id, :account_id
#end
#if table_exists?(:portfolio_import_configurations) && column_exists?(:portfolio_import_configurations, :client_company_id)
rename_column :portfolio_import_configurations, :client_company_id, :account_id
#end
#if table_exists?(:task_settings) && column_exists?(:task_settings, :client_company_id)
rename_column :task_settings, :client_company_id, :account_id
#end
#if table_exists?(:api_clients) && column_exists?(:api_clients, :client_company_id)
rename_column :api_clients, :client_company_id, :account_id
#end
reversible do |dir|
dir.up { update_view :lease_connections, version: 7, revert_to_version: 6 }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment