diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-04-11 14:16:33 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-04-11 14:16:33 +0000 |
commit | 568052b0c637f99462855c043819aa0dd347ff06 (patch) | |
tree | 891a142b8fe451ec5ee0828278113ef3b11dc0f0 | |
parent | a9ff23407c9df7da171b4ad07d40ff8a3f4fac24 (diff) | |
parent | 962bf01e69add14bceb3a901a143fcfba486abf3 (diff) | |
download | gitlab-ce-568052b0c637f99462855c043819aa0dd347ff06.tar.gz |
Merge branch 'zj-fk-ci-triggers' into 'master'
Add foreign key on trigger requests
See merge request !10537
-rw-r--r-- | app/models/ci/trigger.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/zj-fk-ci-triggers.yml | 4 | ||||
-rw-r--r-- | db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb | 15 | ||||
-rw-r--r-- | db/schema.rb | 2 |
4 files changed, 22 insertions, 1 deletions
diff --git a/app/models/ci/trigger.rb b/app/models/ci/trigger.rb index b59e235c425..2f64f70685a 100644 --- a/app/models/ci/trigger.rb +++ b/app/models/ci/trigger.rb @@ -7,7 +7,7 @@ module Ci belongs_to :project belongs_to :owner, class_name: "User" - has_many :trigger_requests, dependent: :destroy + has_many :trigger_requests has_one :trigger_schedule, dependent: :destroy validates :token, presence: true, uniqueness: true diff --git a/changelogs/unreleased/zj-fk-ci-triggers.yml b/changelogs/unreleased/zj-fk-ci-triggers.yml new file mode 100644 index 00000000000..9fe708b25c0 --- /dev/null +++ b/changelogs/unreleased/zj-fk-ci-triggers.yml @@ -0,0 +1,4 @@ +--- +title: Add foreign key for ci_trigger_requests on ci_triggers +merge_request: 10537 +author: diff --git a/db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb b/db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb new file mode 100644 index 00000000000..81761c65a9f --- /dev/null +++ b/db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb @@ -0,0 +1,15 @@ +class AddForeighKeyTriggerRequestsTrigger < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key(:ci_trigger_requests, :ci_triggers, column: :trigger_id) + end + + def down + remove_foreign_key(:ci_trigger_requests, column: :trigger_id) + end +end diff --git a/db/schema.rb b/db/schema.rb index 3422847d729..5689f7331dc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,6 +12,7 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20170408033905) do + # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "pg_trgm" @@ -1356,6 +1357,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do 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_pipelines", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_262d4c2d19", on_delete: :nullify + add_foreign_key "ci_trigger_requests", "ci_triggers", column: "trigger_id", name: "fk_b8ec8b7245", on_delete: :cascade add_foreign_key "ci_trigger_schedules", "ci_triggers", column: "trigger_id", name: "fk_90a406cc94", on_delete: :cascade add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade add_foreign_key "container_repositories", "projects" |