Commit 6cb4dc61 authored by Evan Read's avatar Evan Read

Merge branch 'migration-style-guide-docs' into 'master'

Update Migration Style Guide. Remove MySQL mentions

See merge request gitlab-org/gitlab-ce!31531
parents 00223f91 19f36a34
...@@ -10,9 +10,7 @@ migrations are written carefully, can be applied online and adhere to the style ...@@ -10,9 +10,7 @@ migrations are written carefully, can be applied online and adhere to the style
guide below. guide below.
Migrations are **not** allowed to require GitLab installations to be taken Migrations are **not** allowed to require GitLab installations to be taken
offline unless _absolutely necessary_. Downtime assumptions should be based on offline unless _absolutely necessary_.
the behaviour of a migration when performed using PostgreSQL, as various
operations in MySQL may require downtime without there being alternatives.
When downtime is necessary the migration has to be approved by: When downtime is necessary the migration has to be approved by:
...@@ -343,10 +341,7 @@ class AddOptionsToBuildMetadata < ActiveRecord::Migration[5.0] ...@@ -343,10 +341,7 @@ class AddOptionsToBuildMetadata < ActiveRecord::Migration[5.0]
end end
``` ```
On MySQL the `JSON` and `JSONB` is translated to `TEXT 1MB`, as `JSONB` is PostgreSQL only feature. You have to use a serializer to provide a translation layer:
For above reason you have to use a serializer to provide a translation layer
in order to support PostgreSQL and MySQL seamlessly:
```ruby ```ruby
class BuildMetadata class BuildMetadata
...@@ -356,7 +351,7 @@ end ...@@ -356,7 +351,7 @@ end
## Testing ## Testing
Make sure that your migration works with MySQL and PostgreSQL with data. An Make sure that your migration works for databases with data. An
empty database does not guarantee that your migration is correct. empty database does not guarantee that your migration is correct.
Make sure your migration can be reversed. Make sure your migration can be reversed.
......
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