diff options
Diffstat (limited to 'db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb')
-rw-r--r-- | db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb b/db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb new file mode 100644 index 00000000000..a591596c74c --- /dev/null +++ b/db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class RemoveAnalyticsRepositoryTableFksOnProjects < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + # Requires ExclusiveLock on all tables. analytics_* tables are empty + remove_foreign_key :analytics_repository_files, :projects + remove_foreign_key :analytics_repository_file_edits, :projects + remove_foreign_key :analytics_repository_file_commits, :projects + end + end + + def down + with_lock_retries do + # rubocop:disable Migration/AddConcurrentForeignKey + add_foreign_key :analytics_repository_files, :projects, on_delete: :cascade + add_foreign_key :analytics_repository_file_edits, :projects, on_delete: :cascade + add_foreign_key :analytics_repository_file_commits, :projects, on_delete: :cascade + # rubocop:enable Migration/AddConcurrentForeignKey + end + end +end |