diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-03-15 15:30:16 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-03-15 15:30:16 +0300 |
commit | bd5510539b6130938b25227c7010aaca1ad49fb8 (patch) | |
tree | b3210fa89c0188a2597fa74e32c0a198c2286da9 /lib | |
parent | 9c8a9657c9d40a7f4a9ec5d46a09597dcbe8b88c (diff) | |
parent | 5f35ea146adf3b96546e5dc6f69927d6ad7bcb1c (diff) |
Merge branch 'ab-44205-user_interacted_projects-migration' into 'master'
Fix concurrency issue with migration for user_interacted_projects table.
Closes #44205
See merge request gitlab-org/gitlab-ce!17728
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index dbe6259fce7..21287a8efd0 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -859,6 +859,19 @@ into similar problems in the future (e.g. when new tables are created). BackgroundMigrationWorker.perform_in(delay_interval * index, job_class_name, [start_id, end_id]) end end + + def foreign_key_exists?(table, column) + foreign_keys(table).any? do |key| + key.options[:column] == column.to_s + end + end + + # Rails' index_exists? doesn't work when you only give it a table and index + # name. As such we have to use some extra code to check if an index exists for + # a given name. + def index_exists_by_name?(table, index) + indexes(table).map(&:name).include?(index) + end end end end |