Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20200525121014_drop_users_ghost_column.rb')
-rw-r--r--db/post_migrate/20200525121014_drop_users_ghost_column.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/db/post_migrate/20200525121014_drop_users_ghost_column.rb b/db/post_migrate/20200525121014_drop_users_ghost_column.rb
new file mode 100644
index 00000000000..1f80bc74b9d
--- /dev/null
+++ b/db/post_migrate/20200525121014_drop_users_ghost_column.rb
@@ -0,0 +1,29 @@
+# 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