BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
455d4e25
Commit
455d4e25
authored
May 11, 2017
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj-clean-up-ci-variables-table' into 'master'
Clean up ci variables table Closes #31799 See merge request !11186
parents
466564d9
d922f545
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
5 deletions
+48
-5
project.rb
app/models/project.rb
+1
-1
zj-clean-up-ci-variables-table.yml
changelogs/unreleased/zj-clean-up-ci-variables-table.yml
+4
-0
20170508153950_add_not_null_contraints_to_ci_variables.rb
...20170508153950_add_not_null_contraints_to_ci_variables.rb
+12
-0
20170508190732_add_foreign_key_to_ci_variables.rb
db/migrate/20170508190732_add_foreign_key_to_ci_variables.rb
+24
-0
schema.rb
db/schema.rb
+4
-3
variables.rb
spec/factories/ci/variables.rb
+2
-0
variable_spec.rb
spec/models/ci/variable_spec.rb
+1
-1
No files found.
app/models/project.rb
View file @
455d4e25
...
...
@@ -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
...
...
changelogs/unreleased/zj-clean-up-ci-variables-table.yml
0 → 100644
View file @
455d4e25
---
title
:
Cleanup ci_variables schema and table
merge_request
:
author
:
db/migrate/20170508153950_add_not_null_contraints_to_ci_variables.rb
0 → 100644
View file @
455d4e25
class
AddNotNullContraintsToCiVariables
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
up
change_column
(
:ci_variables
,
:key
,
:string
,
null:
false
)
change_column
(
:ci_variables
,
:project_id
,
:integer
,
null:
false
)
end
def
down
# no op
end
end
db/migrate/20170508190732_add_foreign_key_to_ci_variables.rb
0 → 100644
View file @
455d4e25
class
AddForeignKeyToCiVariables
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
execute
<<~
SQL
DELETE FROM ci_variables
WHERE NOT EXISTS (
SELECT true
FROM projects
WHERE projects.id = ci_variables.project_id
)
SQL
add_concurrent_foreign_key
(
:ci_variables
,
:projects
,
column: :project_id
)
end
def
down
remove_foreign_key
(
:ci_variables
,
column: :project_id
)
end
end
db/schema.rb
View file @
455d4e25
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201705081
70547
)
do
ActiveRecord
::
Schema
.
define
(
version:
201705081
90732
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -347,12 +347,12 @@ ActiveRecord::Schema.define(version: 20170508170547) do
add_index
"ci_triggers"
,
[
"project_id"
],
name:
"index_ci_triggers_on_project_id"
,
using: :btree
create_table
"ci_variables"
,
force: :cascade
do
|
t
|
t
.
string
"key"
t
.
string
"key"
,
null:
false
t
.
text
"value"
t
.
text
"encrypted_value"
t
.
string
"encrypted_value_salt"
t
.
string
"encrypted_value_iv"
t
.
integer
"project_id"
t
.
integer
"project_id"
,
null:
false
end
add_index
"ci_variables"
,
[
"project_id"
],
name:
"index_ci_variables_on_project_id"
,
using: :btree
...
...
@@ -1417,6 +1417,7 @@ ActiveRecord::Schema.define(version: 20170508170547) do
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_triggers"
,
"users"
,
column:
"owner_id"
,
name:
"fk_e8e10d1964"
,
on_delete: :cascade
add_foreign_key
"ci_variables"
,
"projects"
,
name:
"fk_ada5eb64b3"
,
on_delete: :cascade
add_foreign_key
"container_repositories"
,
"projects"
add_foreign_key
"issue_assignees"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"issue_assignees"
,
"users"
,
on_delete: :cascade
...
...
spec/factories/ci/variables.rb
View file @
455d4e25
...
...
@@ -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
spec/models/ci/variable_spec.rb
View file @
455d4e25
require
'spec_helper'
describe
Ci
::
Variable
,
models:
true
do
subject
{
Ci
::
Variable
.
new
}
subject
{
build
(
:ci_variable
)
}
let
(
:secret_value
)
{
'secret'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment