diff options
Diffstat (limited to 'db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb')
-rw-r--r-- | db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb new file mode 100644 index 00000000000..55bf40ba24d --- /dev/null +++ b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb @@ -0,0 +1,23 @@ +class AddForeignKeyPipelineSchedulesAndPipelines < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + on_delete = + if Gitlab::Database.mysql? + :nullify + else + 'SET NULL' + end + + add_concurrent_foreign_key :ci_pipelines, :ci_pipeline_schedules, + column: :pipeline_schedule_id, on_delete: on_delete + end + + def down + remove_foreign_key :ci_pipelines, column: :pipeline_schedule_id + end +end |