From 4f748f74bc561ed6cc37f2c57077e72c0cda8c9a Mon Sep 17 00:00:00 2001 From: Rydkin Maxim Date: Tue, 21 Mar 2017 00:48:05 +0300 Subject: replace on_delete in migration with database type related expression --- db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb index 5156860586a..46dab852fcf 100644 --- a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb +++ b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb @@ -24,8 +24,15 @@ class AddAutoCanceledByIdToPipeline < ActiveRecord::Migration disable_ddl_transaction! def up + on_delete = + if Database.mysql? + :nullify + else + 'SET NULL' + end + add_column :ci_pipelines, :auto_canceled_by_id, :integer - add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: :nullify + add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete end def down -- cgit v1.2.1