Add IID to designs
What does this MR do?
Migrations
Note: The BackfillDesignIids
migration will be executed inline and it's going to update about 100K rows.
Up:
== 20201030200115 AddIidToDesignManagementDesign: migrating ===================
-- add_column(:design_management_designs, :iid, :integer)
-> 0.0153s
== 20201030200115 AddIidToDesignManagementDesign: migrated (0.0154s) ==========
== 20201030200539 AddIndexOnDesignManagementDesignsIidProjectId: migrating ====
-- transaction_open?()
-> 0.0000s
-- index_exists?(:design_management_designs, [:project_id, :iid], {:name=>"index_design_management_designs_on_iid_and_project_id", :unique=>true, :algorithm=>:concurrently})
-> 0.0072s
-- execute("SET statement_timeout TO 0")
-> 0.0007s
-- add_index(:design_management_designs, [:project_id, :iid], {:name=>"index_design_management_designs_on_iid_and_project_id", :unique=>true, :algorithm=>:concurrently})
-> 0.0136s
-- execute("RESET ALL")
-> 0.0021s
== 20201030200539 AddIndexOnDesignManagementDesignsIidProjectId: migrated (0.0257s)
== 20201030203854 BackfillDesignIids: migrating ===============================
== 20201030203854 BackfillDesignIids: migrated (0.0272s) ======================
== 20201102152554 AddNotNullCheckOnIidOnDesignManangementDesigns: migrating ===
-- current_schema()
-> 0.0004s
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0003s
-- execute("ALTER TABLE design_management_designs\nADD CONSTRAINT check_cfb92df01a\nCHECK ( iid IS NOT NULL )\nNOT VALID;\n")
-> 0.0010s
-- current_schema()
-> 0.0002s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- execute("ALTER TABLE design_management_designs VALIDATE CONSTRAINT check_cfb92df01a;")
-> 0.0027s
-- execute("RESET ALL")
-> 0.0003s
== 20201102152554 AddNotNullCheckOnIidOnDesignManangementDesigns: migrated (0.0230s)
Down:
$ be rake db:rollback STEP=3
== 20201102152554 AddNotNullCheckOnIidOnDesignManangementDesigns: reverting ===
-- execute("ALTER TABLE design_management_designs\nDROP CONSTRAINT IF EXISTS check_cfb92df01a\n")
-> 0.0008s
== 20201102152554 AddNotNullCheckOnIidOnDesignManangementDesigns: reverted (0.0194s)
== 20201030203854 BackfillDesignIids: reverting ===============================
== 20201030203854 BackfillDesignIids: reverted (0.0000s) ======================
== 20201030200539 AddIndexOnDesignManagementDesignsIidProjectId: reverting ====
-- transaction_open?()
-> 0.0000s
-- indexes(:design_management_designs)
-> 0.0040s
-- execute("SET statement_timeout TO 0")
-> 0.0001s
-- remove_index(:design_management_designs, {:algorithm=>:concurrently, :name=>"index_design_management_designs_on_iid_and_project_id"})
-> 0.0034s
-- execute("RESET ALL")
-> 0.0002s
== 20201030200539 AddIndexOnDesignManagementDesignsIidProjectId: reverted (0.0083s)
== 20201030200115 AddIidToDesignManagementDesign: reverting ===================
-- remove_column(:design_management_designs, :iid, :integer)
-> 0.0009s
== 20201030200115 AddIidToDesignManagementDesign: reverted (0.0042s) ==========
State of the table:
gitlabhq_development=# \d design_management_designs;
Table "public.design_management_designs"
Column | Type | Collation | Nullable | Default
-------------------+-------------------+-----------+----------+-------------------------------------------------------
id | bigint | | not null | nextval('design_management_designs_id_seq'::regclass)
project_id | integer | | not null |
issue_id | integer | | |
filename | character varying | | not null |
relative_position | integer | | |
iid | integer | | |
Indexes:
"design_management_designs_pkey" PRIMARY KEY, btree (id)
"index_design_management_designs_issue_id_relative_position_id" btree (issue_id, relative_position, id)
"index_design_management_designs_on_iid_and_project_id" UNIQUE, btree (project_id, iid)
"index_design_management_designs_on_issue_id_and_filename" UNIQUE, btree (issue_id, filename)
"index_design_management_designs_on_project_id" btree (project_id)
Check constraints:
"check_07155e2715" CHECK (char_length(filename::text) <= 255)
Foreign-key constraints:
"fk_rails_4bb1073360" FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
"fk_rails_bfe283ec3c" FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE
Referenced by:
TABLE "design_management_designs_versions" CONSTRAINT "fk_03c671965c" FOREIGN KEY (design_id) REFERENCES design_management_designs(id) ON DELETE CASCADE
TABLE "design_user_mentions" CONSTRAINT "fk_rails_f7075a53c1" FOREIGN KEY (design_id) REFERENCES design_management_designs(id) ON DELETE CASCADE
Screenshots (strongly suggested)
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
Related to #214978 (closed)
Edited by Alex Kalderimis