debian-mirror-gitlab/db/post_migrate/20200525121014_drop_users_ghost_column.rb
2020-06-23 00:09:42 +05:30

29 lines
644 B
Ruby

# frozen_string_literal: true
class DropUsersGhostColumn < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index_by_name :users, 'index_users_on_ghost'
with_lock_retries do
remove_column :users, :ghost
end
end
def down
unless column_exists?(:users, :ghost)
with_lock_retries do
add_column :users, :ghost, :boolean # rubocop:disable Migration/AddColumnsToWideTables
end
end
execute 'UPDATE users set ghost = TRUE WHERE user_type = 5'
add_concurrent_index :users, :ghost
end
end