Commit d922f545 authored by Z.J. van de Weg's avatar Z.J. van de Weg

Remove rails dependent: :destroy statement

Enforced by the database, and no callbacks need to be called.

Combined with 7b9b2c6099 and 294a8b8a6d this resolves
gitlab-org/gitlab-ce#31799
parent 3eb8435f
...@@ -175,7 +175,7 @@ class Project < ActiveRecord::Base ...@@ -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 :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 :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject'
has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner' 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 :triggers, dependent: :destroy, class_name: 'Ci::Trigger'
has_many :environments, dependent: :destroy has_many :environments, dependent: :destroy
has_many :deployments, dependent: :destroy has_many :deployments, dependent: :destroy
......
---
title: Cleanup ci_variables schema and table
merge_request:
author:
...@@ -13,7 +13,6 @@ class AddForeignKeyToCiVariables < ActiveRecord::Migration ...@@ -13,7 +13,6 @@ class AddForeignKeyToCiVariables < ActiveRecord::Migration
FROM projects FROM projects
WHERE projects.id = ci_variables.project_id WHERE projects.id = ci_variables.project_id
) )
OR ci_variables.project_id IS NULL
SQL SQL
add_concurrent_foreign_key(:ci_variables, :projects, column: :project_id) add_concurrent_foreign_key(:ci_variables, :projects, column: :project_id)
......
...@@ -2,5 +2,7 @@ FactoryGirl.define do ...@@ -2,5 +2,7 @@ FactoryGirl.define do
factory :ci_variable, class: Ci::Variable do factory :ci_variable, class: Ci::Variable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value 'VARIABLE_VALUE'
project factory: :empty_project
end end
end end
require 'spec_helper' require 'spec_helper'
describe Ci::Variable, models: true do describe Ci::Variable, models: true do
subject { Ci::Variable.new } subject { build(:ci_variable) }
let(:secret_value) { 'secret' } let(:secret_value) { 'secret' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment