README.md in strong_migrations-0.7.9 vs README.md in strong_migrations-0.8.0
- old
+ new
@@ -13,11 +13,11 @@
## Installation
Add this line to your application’s Gemfile:
```ruby
-gem 'strong_migrations'
+gem "strong_migrations"
```
And run:
```sh
@@ -117,10 +117,11 @@
end
end
```
4. Deploy and run migration
+5. Remove the line added in step 1
### Adding a column with a default value
#### Bad
@@ -538,51 +539,25 @@
end
```
#### Good
-Add the foreign key without validating existing rows, then validate them in a separate migration.
+Add the foreign key without validating existing rows:
-For Rails 5.2+, use:
-
```ruby
class AddForeignKeyOnUsers < ActiveRecord::Migration[7.0]
def change
add_foreign_key :users, :orders, validate: false
end
end
```
-Then:
+Then validate them in a separate migration.
```ruby
class ValidateForeignKeyOnUsers < ActiveRecord::Migration[7.0]
def change
validate_foreign_key :users, :orders
- end
-end
-```
-
-For Rails < 5.2, use:
-
-```ruby
-class AddForeignKeyOnUsers < ActiveRecord::Migration[5.1]
- def change
- safety_assured do
- execute 'ALTER TABLE "users" ADD CONSTRAINT "fk_rails_c1e9b98e31" FOREIGN KEY ("order_id") REFERENCES "orders" ("id") NOT VALID'
- end
- end
-end
-```
-
-Then:
-
-```ruby
-class ValidateForeignKeyOnUsers < ActiveRecord::Migration[5.1]
- def change
- safety_assured do
- execute 'ALTER TABLE "users" VALIDATE CONSTRAINT "fk_rails_c1e9b98e31"'
- end
end
end
```
### Adding a json column