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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
42e8bef3
Commit
42e8bef3
authored
Aug 27, 2019
by
Evan Read
Committed by
Kushal Pandya
Aug 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes trailing whitespace to fix linting
parent
f6d3a47b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
doc/development/migration_style_guide.md
doc/development/migration_style_guide.md
+5
-5
No files found.
doc/development/migration_style_guide.md
View file @
42e8bef3
...
@@ -95,9 +95,9 @@ none of the steps will be executed, leaving the database in valid state.
...
@@ -95,9 +95,9 @@ none of the steps will be executed, leaving the database in valid state.
Therefore, either:
Therefore, either:
-
Put all migrations in one single-transaction migration.
-
Put all migrations in one single-transaction migration.
-
If necessary, put most actions in one migration and create a separate migration
-
If necessary, put most actions in one migration and create a separate migration
for the steps that cannot be done in a single transaction.
for the steps that cannot be done in a single transaction.
For example, if you create an empty table and need to build an index for it,
For example, if you create an empty table and need to build an index for it,
it is recommended to use a regular single-transaction migration and the default
it is recommended to use a regular single-transaction migration and the default
rails schema statement:
[
`add_index`
](
https://api.rubyonrails.org/v5.2/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_index
)
.
rails schema statement:
[
`add_index`
](
https://api.rubyonrails.org/v5.2/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_index
)
.
...
@@ -192,9 +192,9 @@ always _first_ add a migration that removes any duplicates, before adding the
...
@@ -192,9 +192,9 @@ always _first_ add a migration that removes any duplicates, before adding the
unique index.
unique index.
When adding an index to a non-empty table make sure to use the method
When adding an index to a non-empty table make sure to use the method
`add_concurrent_index`
instead of the regular
`add_index`
method.
`add_concurrent_index`
instead of the regular
`add_index`
method.
The
`add_concurrent_index`
method automatically creates concurrent indexes
The
`add_concurrent_index`
method automatically creates concurrent indexes
when using PostgreSQL, removing the need for downtime.
when using PostgreSQL, removing the need for downtime.
To use this method, you must disable single-transactions mode
To use this method, you must disable single-transactions mode
by calling the method
`disable_ddl_transaction!`
in the body of your migration
by calling the method
`disable_ddl_transaction!`
in the body of your migration
...
@@ -216,7 +216,7 @@ class MyMigration < ActiveRecord::Migration[4.2]
...
@@ -216,7 +216,7 @@ class MyMigration < ActiveRecord::Migration[4.2]
end
end
```
```
For a small table (such as an empty one or one with less than
`1,000`
records),
For a small table (such as an empty one or one with less than
`1,000`
records),
it is recommended to use
`add_index`
in a single-transaction migration, combining it with other
it is recommended to use
`add_index`
in a single-transaction migration, combining it with other
operations that don't require
`disable_ddl_transaction!`
.
operations that don't require
`disable_ddl_transaction!`
.
...
...
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