Add dedicated group relation to user & group classes
What does this MR do?
This MR creates a database structure for storing account information for provisioned dedicated group accounts. See more in https://gitlab.com/gitlab-org/gitlab-ee/issues/6260
Add a description of your merge request here.
Database checklist
-
Conforms to the database guides
When adding migrations:
-
Updated db/schema.rb
-
Added a down
method so the migration can be reverted -
Added the output of the migration(s) to the MR body -
Added tests for the migration in spec/migrations
if necessary (e.g. when migrating data)
When adding or modifying queries to improve performance:
-
Included data that shows the performance improvement, preferably in the form of a benchmark -
Included the output of EXPLAIN (ANALYZE, BUFFERS)
of the relevant queries
When adding foreign keys to existing tables:
-
Included a migration to remove orphaned rows in the source table before adding the foreign key -
Removed any instances of dependent: ...
that may no longer be necessary
When adding tables:
-
Ordered columns based on the Ordering Table Columns guidelines -
Added foreign keys to any columns pointing to data in other tables -
Added indexes for fields that are used in statements such as WHERE, ORDER BY, GROUP BY, and JOINs
When removing columns, tables, indexes or other structures:
-
Removed these in a post-deployment migration -
Made sure the application no longer uses (or ignores) these structures
General checklist
-
Changelog entry added, if necessary -
Documentation created/updated -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides
Migration outputs:
== 20190222105948 AddUserManagingGroupRelation: migrating =====================
-- add_column(:users, :managing_group_id, :integer)
-> 0.0030s
== 20190222105948 AddUserManagingGroupRelation: migrated (0.0031s) ============
== 20190222110418 AddUserManagingGroupRelationFk: migrating ===================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:users, :managing_group_id, {:algorithm=>:concurrently})
-> 0.0096s
-- execute("SET statement_timeout TO 0")
-> 0.0004s
-- add_index(:users, :managing_group_id, {:algorithm=>:concurrently})
-> 0.0082s
-- execute("RESET ALL")
-> 0.0004s
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:users)
-> 0.0032s
-- execute("ALTER TABLE users\nADD CONSTRAINT fk_a4b8fefe3e\nFOREIGN KEY (managing_group_id)\nREFERENCES namespaces (id)\nON DELETE SET NULL\nNOT VALID;\n")
-> 0.0100s
-- execute("SET statement_timeout TO 0")
-> 0.0004s
-- execute("ALTER TABLE users VALIDATE CONSTRAINT fk_a4b8fefe3e;")
-> 0.0033s
-- execute("RESET ALL")
-> 0.0005s
== 20190222110418 AddUserManagingGroupRelationFk: migrated (0.0370s) ==========
Edited by Pavel Shutsin