Drop obsolete ghost column
What does this MR do?
It removes "users.ghost" DB column because we don't use it anymore.
You can use WHERE user_type = 5
to retrieve the same set of users.
Migrations output
➜ gitlab-rails git:(219002-remove-ghost-column) ✗ be rake db:migrate
== 20200525114553 RenameUserTypeIndex: migrating ==============================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:users, [:state, :user_type], {:name=>"index_users_on_state_and_user_type", :algorithm=>:concurrently})
-> 0.0417s
-- add_index(:users, [:state, :user_type], {:name=>"index_users_on_state_and_user_type", :algorithm=>:concurrently})
-> 0.0117s
-- transaction_open?()
-> 0.0000s
-- indexes(:users)
-> 0.0454s
-- remove_index(:users, {:algorithm=>:concurrently, :name=>"index_users_on_state_and_user_type_internal"})
-> 0.0032s
== 20200525114553 RenameUserTypeIndex: migrated (0.1053s) =====================
➜ gitlab-rails git:(219002-remove-ghost-column) ✗ be rake db:migrate:down VERSION=20200525114553
== 20200525114553 RenameUserTypeIndex: reverting ==============================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:users, [:state, :user_type], {:where=>"ghost IS NOT TRUE", :name=>"index_users_on_state_and_user_type_internal", :algorithm=>:concurrently})
-> 0.0341s
-- add_index(:users, [:state, :user_type], {:where=>"ghost IS NOT TRUE", :name=>"index_users_on_state_and_user_type_internal", :algorithm=>:concurrently})
-> 0.0087s
-- transaction_open?()
-> 0.0000s
-- indexes(:users)
-> 0.0328s
-- remove_index(:users, {:algorithm=>:concurrently, :name=>"index_users_on_state_and_user_type"})
-> 0.0022s
== 20200525114553 RenameUserTypeIndex: reverted (0.0802s) =====================
gitlab-rails git:(219002-remove-ghost-column) ✗ be rake db:migrate
WARNING: This version of GitLab depends on gitlab-shell 13.2.0, but you're running Unknown. Please update gitlab-shell.
== 20200525121014 DropUsersGhostColumn: migrating =============================
-- transaction_open?()
-> 0.0000s
-- indexes(:users)
-> 0.0374s
-- remove_index(:users, {:algorithm=>:concurrently, :name=>"index_users_on_ghost"})
-> 0.0050s
-- remove_column(:users, :ghost)
-> 0.0017s
== 20200525121014 DropUsersGhostColumn: migrated (0.0571s) ====================
➜ gitlab-rails git:(219002-remove-ghost-column) ✗ be rake db:migrate:down VERSION=20200525121014
WARNING: This version of GitLab depends on gitlab-shell 13.2.0, but you're running Unknown. Please update gitlab-shell.
== 20200525121014 DropUsersGhostColumn: reverting =============================
-- column_exists?(:users, :ghost)
-> 0.0084s
-- add_column(:users, :ghost, :boolean)
-> 0.0018s
-- execute("UPDATE users set ghost = TRUE WHERE user_type = 5")
-> 0.0033s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:users, :ghost, {:algorithm=>:concurrently})
-> 0.0316s
-- add_index(:users, :ghost, {:algorithm=>:concurrently})
-> 0.0082s
== 20200525121014 DropUsersGhostColumn: reverted (0.0661s) ====================
Data sync check
explain select * from users where (ghost IS TRUE and user_type != 5) OR (ghost IS FALSE and user_type = 5)
Bitmap Heap Scan on public.users (cost=4.13..5.65 rows=1 width=1229) (actual time=0.034..0.035 rows=0 loops=1)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes #219002 (closed)
Edited by Yorick Peterse