diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-08 21:56:37 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-11 13:26:33 +0200 |
commit | df710ae475186c70d689711ebd4050887d864cfb (patch) | |
tree | d9d8db58d559ea35a1301b6eab7125ac5499b510 | |
parent | 29dc82a56fdf8415d41b03ad6dc8e072993796ce (diff) | |
download | gitlab-ce-zj-clean-up-ci-variables-table.tar.gz |
Remove rails dependent: :destroy statementzj-clean-up-ci-variables-table
Enforced by the database, and no callbacks need to be called.
Combined with 7b9b2c6099 and 294a8b8a6d this resolves
gitlab-org/gitlab-ce#31799
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/zj-clean-up-ci-variables-table.yml | 4 | ||||
-rw-r--r-- | db/post_migrate/20170508190732_add_foreign_key_to_ci_variables.rb | 1 | ||||
-rw-r--r-- | spec/factories/ci/variables.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/variable_spec.rb | 2 |
5 files changed, 8 insertions, 3 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index be4960aef8a..65745fd6d37 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -175,7 +175,7 @@ class Project < ActiveRecord::Base has_many :builds, class_name: 'Ci::Build' # the builds are created from the commit_statuses has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject' has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner' - has_many :variables, dependent: :destroy, class_name: 'Ci::Variable' + has_many :variables, class_name: 'Ci::Variable' has_many :triggers, dependent: :destroy, class_name: 'Ci::Trigger' has_many :environments, dependent: :destroy has_many :deployments, dependent: :destroy diff --git a/changelogs/unreleased/zj-clean-up-ci-variables-table.yml b/changelogs/unreleased/zj-clean-up-ci-variables-table.yml new file mode 100644 index 00000000000..ea2db40d590 --- /dev/null +++ b/changelogs/unreleased/zj-clean-up-ci-variables-table.yml @@ -0,0 +1,4 @@ +--- +title: Cleanup ci_variables schema and table +merge_request: +author: diff --git a/db/post_migrate/20170508190732_add_foreign_key_to_ci_variables.rb b/db/post_migrate/20170508190732_add_foreign_key_to_ci_variables.rb index 13837324787..20ecaa2c36c 100644 --- a/db/post_migrate/20170508190732_add_foreign_key_to_ci_variables.rb +++ b/db/post_migrate/20170508190732_add_foreign_key_to_ci_variables.rb @@ -13,7 +13,6 @@ class AddForeignKeyToCiVariables < ActiveRecord::Migration FROM projects WHERE projects.id = ci_variables.project_id ) - OR ci_variables.project_id IS NULL SQL add_concurrent_foreign_key(:ci_variables, :projects, column: :project_id) diff --git a/spec/factories/ci/variables.rb b/spec/factories/ci/variables.rb index 6653f0bb5c3..c5fba597c1c 100644 --- a/spec/factories/ci/variables.rb +++ b/spec/factories/ci/variables.rb @@ -2,5 +2,7 @@ FactoryGirl.define do factory :ci_variable, class: Ci::Variable do sequence(:key) { |n| "VARIABLE_#{n}" } value 'VARIABLE_VALUE' + + project factory: :empty_project end end diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb index 048d25869bc..fe8c52d5353 100644 --- a/spec/models/ci/variable_spec.rb +++ b/spec/models/ci/variable_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Ci::Variable, models: true do - subject { Ci::Variable.new } + subject { build(:ci_variable) } let(:secret_value) { 'secret' } |