Modify namespace name and path validation
What does this MR do?
- Allow same namespace name with different parent_id
- Allow same namespace path. Uniq validation should be handled by routes table
Are there points in the code the reviewer needs to double check?
migrations
Why was this MR needed?
So we can use same name in different nesting like:
gitlab-ce/foo
gitlab-com/foo
foo/gitlab-ce
Screenshots (if relevant)
no
Does this MR meet the acceptance criteria?
Changelog entry addedDocumentation created/updatedAPI support added- Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
What are the relevant issue numbers?
Merge request reports
Activity
mentioned in merge request !7976 (closed)
added 34 commits
-
cd5a47b2...3f768f9a - 33 commits from branch
master
- 4efa2cb1 - Modify namespace name and path validation
-
cd5a47b2...3f768f9a - 33 commits from branch
marked the task Squashed related commits together as completed
marked the task Conform by the style guides as completed
marked the task Conform by the merge request performance guides as completed
assigned to @smcgivern
6 6 it { is_expected.to have_many :projects } 7 7 8 8 it { is_expected.to validate_presence_of(:name) } 9 it { is_expected.to validate_uniqueness_of(:name) } 9 it { is_expected.to validate_uniqueness_of(:name).scoped_to(:parent_id) } @smcgivern I don't think so. Its completely rails feature and I dont want us overtest it
5 include Gitlab::Database::MigrationHelpers 6 7 disable_ddl_transaction! 8 9 DOWNTIME = false 10 11 def up 12 constraint_name = 'namespaces_path_key' 13 14 transaction do 15 if index_exists?(:namespaces, :path) 16 remove_index(:namespaces, :path) 17 end 18 19 # In some bizarre cases PostgreSQL might have a separate unique constraint 20 # that we'll need to drop. @smcgivern I copied it from somewhat identical migration
./db/migrate/20160725104020_merge_request_diff_remove_uniq.rb
just to make sure we don't hit it once againAh, I see - fd4ad654 explains it. Wdyt about adding a table param to
constraint_exists?
and moving it to the migration helpers?
@dzaporozhets LGTM, two questions.
assigned to @dzaporozhets
@smcgivern thanks. I am going to merge it but please checkout my comments so I can improve in separate MR if needed
mentioned in commit 4bdfb039
added 169 commits
-
161d7c02...b70b9628 - 168 commits from branch
master
- 4bdfb039 - Merge branch 'master' into 'dz-remove-namespaces-path-uniq'
-
161d7c02...b70b9628 - 168 commits from branch
mentioned in commit abad9a9b