README.md in strong_migrations-0.7.2 vs README.md in strong_migrations-0.7.3
- old
+ new
@@ -6,11 +6,11 @@
Supports for PostgreSQL, MySQL, and MariaDB
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
-[![Build Status](https://travis-ci.org/ankane/strong_migrations.svg?branch=master)](https://travis-ci.org/ankane/strong_migrations)
+[![Build Status](https://github.com/ankane/strong_migrations/workflows/build/badge.svg?branch=master)](https://github.com/ankane/strong_migrations/actions)
## Installation
Add this line to your application’s Gemfile:
@@ -309,10 +309,12 @@
If you intend to drop an existing table, run `drop_table` first.
### Setting NOT NULL on an existing column
+:turtle: Safe by default available
+
#### Bad
Setting `NOT NULL` on an existing column blocks reads and writes while every row is checked.
```ruby
@@ -371,10 +373,12 @@
end
```
### Adding an index non-concurrently
+:turtle: Safe by default available
+
#### Bad
In Postgres, adding an index non-concurrently blocks writes.
```ruby
@@ -407,10 +411,12 @@
rails g index table column
```
### Adding a reference
+:turtle: Safe by default available
+
#### Bad
Rails adds an index non-concurrently to references by default, which blocks writes in Postgres.
```ruby
@@ -435,10 +441,12 @@
end
```
### Adding a foreign key
+:turtle: Safe by default available
+
#### Bad
In Postgres, adding a foreign key blocks writes on both tables.
```ruby
@@ -572,9 +580,23 @@
end
end
```
Certain methods like `execute` and `change_table` cannot be inspected and are prevented from running by default. Make sure what you’re doing is really safe and use this pattern.
+
+## Safe by Default [experimental]
+
+Make operations safe by default.
+
+- adding and removing an index
+- adding a foreign key
+- setting NOT NULL on an existing column
+
+Add to `config/initializers/strong_migrations.rb`:
+
+```ruby
+StrongMigrations.safe_by_default = true
+```
## Custom Checks
Add your own custom checks with: