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
Jérome Perrin
gitlab-ce
Commits
8033afd8
Commit
8033afd8
authored
Jun 15, 2016
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update migration_style_guide.md with new details
parent
1a832c8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
doc/development/migration_style_guide.md
doc/development/migration_style_guide.md
+14
-2
No files found.
doc/development/migration_style_guide.md
View file @
8033afd8
...
@@ -34,6 +34,15 @@ First, you need to provide information on whether the migration can be applied:
...
@@ -34,6 +34,15 @@ First, you need to provide information on whether the migration can be applied:
3.
online with errors on new instances while migrating
3.
online with errors on new instances while migrating
4.
offline (needs to happen without app servers to prevent db corruption)
4.
offline (needs to happen without app servers to prevent db corruption)
For example:
```
# rubocop:disable all
# Migration type: online without errors (works on previous version and new one)
class MyMigration < ActiveRecord::Migration
...
```
It is always preferable to have a migration run online. If you expect the migration
It is always preferable to have a migration run online. If you expect the migration
to take particularly long (for instance, if it loops through all notes),
to take particularly long (for instance, if it loops through all notes),
this is valuable information to add.
this is valuable information to add.
...
@@ -48,7 +57,6 @@ be possible to downgrade in case of a vulnerability or bugs.
...
@@ -48,7 +57,6 @@ be possible to downgrade in case of a vulnerability or bugs.
In your migration, add a comment describing how the reversibility of the
In your migration, add a comment describing how the reversibility of the
migration was tested.
migration was tested.
## Removing indices
## Removing indices
If you need to remove index, please add a condition like in following example:
If you need to remove index, please add a condition like in following example:
...
@@ -70,6 +78,7 @@ so:
...
@@ -70,6 +78,7 @@ so:
```
```
class MyMigration < ActiveRecord::Migration
class MyMigration < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
disable_ddl_transaction!
def change
def change
...
@@ -90,8 +99,11 @@ value of `10` you'd write the following:
...
@@ -90,8 +99,11 @@ value of `10` you'd write the following:
```
```
class MyMigration < ActiveRecord::Migration
class MyMigration < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
def up
add_column_with_default(:projects, :foo, :integer, 10)
add_column_with_default(:projects, :foo, :integer,
default:
10)
end
end
def down
def down
...
...
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