Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
89aed37e
Commit
89aed37e
authored
Dec 23, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make migrations reversible
parent
9f69a0b2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
12 additions
and
5 deletions
+12
-5
db/migrate/20151203162134_add_build_events_to_services.rb
db/migrate/20151203162134_add_build_events_to_services.rb
+1
-1
db/migrate/20151209144329_migrate_ci_web_hooks.rb
db/migrate/20151209144329_migrate_ci_web_hooks.rb
+3
-0
db/migrate/20151210125928_add_ci_to_project.rb
db/migrate/20151210125928_add_ci_to_project.rb
+1
-1
db/migrate/20151210125929_add_project_id_to_ci.rb
db/migrate/20151210125929_add_project_id_to_ci.rb
+1
-1
db/migrate/20151210125930_migrate_ci_to_project.rb
db/migrate/20151210125930_migrate_ci_to_project.rb
+4
-0
db/migrate/20151210125931_add_index_to_ci_tables.rb
db/migrate/20151210125931_add_index_to_ci_tables.rb
+1
-1
db/migrate/20151210125932_drop_null_for_ci_tables.rb
db/migrate/20151210125932_drop_null_for_ci_tables.rb
+1
-1
No files found.
db/migrate/20151203162134_add_build_events_to_services.rb
View file @
89aed37e
class
AddBuildEventsToServices
<
ActiveRecord
::
Migration
class
AddBuildEventsToServices
<
ActiveRecord
::
Migration
def
up
def
change
add_column
:services
,
:build_events
,
:boolean
,
default:
false
,
null:
false
add_column
:services
,
:build_events
,
:boolean
,
default:
false
,
null:
false
add_column
:web_hooks
,
:build_events
,
:boolean
,
default:
false
,
null:
false
add_column
:web_hooks
,
:build_events
,
:boolean
,
default:
false
,
null:
false
end
end
...
...
db/migrate/20151209144329_migrate_ci_web_hooks.rb
View file @
89aed37e
...
@@ -10,4 +10,7 @@ class MigrateCiWebHooks < ActiveRecord::Migration
...
@@ -10,4 +10,7 @@ class MigrateCiWebHooks < ActiveRecord::Migration
'JOIN projects ON ci_projects.gitlab_id = projects.id'
'JOIN projects ON ci_projects.gitlab_id = projects.id'
)
)
end
end
def
down
end
end
end
db/migrate/20151210125928_add_ci_to_project.rb
View file @
89aed37e
class
AddCiToProject
<
ActiveRecord
::
Migration
class
AddCiToProject
<
ActiveRecord
::
Migration
def
up
def
change
add_column
:projects
,
:ci_id
,
:integer
add_column
:projects
,
:ci_id
,
:integer
add_column
:projects
,
:builds_enabled
,
:boolean
,
default:
true
,
null:
false
add_column
:projects
,
:builds_enabled
,
:boolean
,
default:
true
,
null:
false
add_column
:projects
,
:shared_runners_enabled
,
:boolean
,
default:
true
,
null:
false
add_column
:projects
,
:shared_runners_enabled
,
:boolean
,
default:
true
,
null:
false
...
...
db/migrate/20151210125929_add_project_id_to_ci.rb
View file @
89aed37e
class
AddProjectIdToCi
<
ActiveRecord
::
Migration
class
AddProjectIdToCi
<
ActiveRecord
::
Migration
def
up
def
change
add_column
:ci_builds
,
:gl_project_id
,
:integer
add_column
:ci_builds
,
:gl_project_id
,
:integer
add_column
:ci_runner_projects
,
:gl_project_id
,
:integer
add_column
:ci_runner_projects
,
:gl_project_id
,
:integer
add_column
:ci_triggers
,
:gl_project_id
,
:integer
add_column
:ci_triggers
,
:gl_project_id
,
:integer
...
...
db/migrate/20151210125930_migrate_ci_to_project.rb
View file @
89aed37e
...
@@ -14,6 +14,10 @@ class MigrateCiToProject < ActiveRecord::Migration
...
@@ -14,6 +14,10 @@ class MigrateCiToProject < ActiveRecord::Migration
migrate_ci_service
migrate_ci_service
end
end
def
down
# We can't reverse the data
end
def
migrate_project_id_for_table
(
table
)
def
migrate_project_id_for_table
(
table
)
subquery
=
"SELECT gitlab_id FROM ci_projects WHERE ci_projects.id =
#{
table
}
.project_id"
subquery
=
"SELECT gitlab_id FROM ci_projects WHERE ci_projects.id =
#{
table
}
.project_id"
execute
(
"UPDATE
#{
table
}
SET gl_project_id=(
#{
subquery
}
) WHERE gl_project_id IS NULL"
)
execute
(
"UPDATE
#{
table
}
SET gl_project_id=(
#{
subquery
}
) WHERE gl_project_id IS NULL"
)
...
...
db/migrate/20151210125931_add_index_to_ci_tables.rb
View file @
89aed37e
class
AddIndexToCiTables
<
ActiveRecord
::
Migration
class
AddIndexToCiTables
<
ActiveRecord
::
Migration
def
up
def
change
add_index
:ci_builds
,
:gl_project_id
add_index
:ci_builds
,
:gl_project_id
add_index
:ci_runner_projects
,
:gl_project_id
add_index
:ci_runner_projects
,
:gl_project_id
add_index
:ci_triggers
,
:gl_project_id
add_index
:ci_triggers
,
:gl_project_id
...
...
db/migrate/20151210125932_drop_null_for_ci_tables.rb
View file @
89aed37e
class
DropNullForCiTables
<
ActiveRecord
::
Migration
class
DropNullForCiTables
<
ActiveRecord
::
Migration
def
up
def
change
remove_index
:ci_variables
,
:project_id
remove_index
:ci_variables
,
:project_id
remove_index
:ci_runner_projects
,
:project_id
remove_index
:ci_runner_projects
,
:project_id
change_column_null
:ci_triggers
,
:project_id
,
true
change_column_null
:ci_triggers
,
:project_id
,
true
...
...
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