@@ -40,3 +40,49 @@ be possible to downgrade in case of a vulnerability or bugs.
...
@@ -40,3 +40,49 @@ 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
If you need to remove index, please add a condition like in following example:
```
remove_index :namespaces, column: :name if index_exists?(:namespaces, :name)
```
## Adding indices
If you need to add an unique index please keep in mind there is possibility of existing duplicates. If it is possible write a separate migration for handling this situation. It can be just removing or removing with overwriting all references to these duplicates depend on situation.
## Testing
Make sure that your migration works with MySQL and PostgreSQL with data. An empty database does not guarantee that your migration is correct.
Make sure your migration can be reversed.
## Data migration
Please prefer Arel and plain SQL over usual ActiveRecord syntax. In case of using plain SQL you need to quote all input manually with `quote_string` helper.