diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20170526190708_create_foreign_keys_for_pipeline_stages.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/db/post_migrate/20170526190708_create_foreign_keys_for_pipeline_stages.rb b/db/post_migrate/20170526190708_create_foreign_keys_for_pipeline_stages.rb new file mode 100644 index 00000000000..40060d12d74 --- /dev/null +++ b/db/post_migrate/20170526190708_create_foreign_keys_for_pipeline_stages.rb @@ -0,0 +1,17 @@ +class CreateForeignKeysForPipelineStages < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :ci_stages, :projects, column: :project_id, on_delete: :cascade + add_concurrent_foreign_key :ci_builds, :ci_stages, column: :stage_id, on_delete: :cascade + end + + def down + remove_foreign_key :ci_stages, column: :project_id + remove_foreign_key :ci_builds, column: :stage_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 87e16e2f69c..f3bd9c26fb4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170526185921) do +ActiveRecord::Schema.define(version: 20170526190708) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1429,10 +1429,12 @@ ActiveRecord::Schema.define(version: 20170526185921) do add_foreign_key "boards", "projects" add_foreign_key "chat_teams", "namespaces", on_delete: :cascade add_foreign_key "ci_builds", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_a2141b1522", on_delete: :nullify + add_foreign_key "ci_builds", "ci_stages", column: "stage_id", name: "fk_3a9eaa254d", on_delete: :cascade add_foreign_key "ci_pipeline_schedules", "projects", name: "fk_8ead60fcc4", on_delete: :cascade add_foreign_key "ci_pipeline_schedules", "users", column: "owner_id", name: "fk_9ea99f58d2", on_delete: :nullify add_foreign_key "ci_pipelines", "ci_pipeline_schedules", column: "pipeline_schedule_id", name: "fk_3d34ab2e06", on_delete: :nullify add_foreign_key "ci_pipelines", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_262d4c2d19", on_delete: :nullify + add_foreign_key "ci_stages", "projects", name: "fk_2360681d1d", on_delete: :cascade add_foreign_key "ci_trigger_requests", "ci_triggers", column: "trigger_id", name: "fk_b8ec8b7245", on_delete: :cascade add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade add_foreign_key "ci_variables", "projects", name: "fk_ada5eb64b3", on_delete: :cascade |