README.md in strong_migrations-0.6.6 vs README.md in strong_migrations-0.6.7

- old
+ new

@@ -19,10 +19,11 @@ ``` And run: ```sh +bundle install rails generate strong_migrations:install ``` ## Checks @@ -38,12 +39,11 @@ - [using change_column_null with a default value](#using-change_column_null-with-a-default-value) - [executing SQL directly](#executing-SQL-directly) Postgres-specific checks: -- [adding an index non-concurrently](#adding-an-index) -- [removing an index non-concurrently](#removing-an-index) +- [adding an index non-concurrently](#adding-an-index-non-concurrently) - [adding a reference](#adding-a-reference) - [adding a foreign key](#adding-a-foreign-key) - [adding a json column](#adding-a-json-column) - [setting NOT NULL on an existing column](#setting-not-null-on-an-existing-column) @@ -255,10 +255,12 @@ end end end ``` +If you intend to drop an existing table, run `drop_table` first. + ### Using change_column_null with a default value #### Bad This generates a single `UPDATE` statement to set the default value. @@ -295,11 +297,11 @@ safety_assured { execute "..." } end end ``` -### Adding an index +### Adding an index non-concurrently #### Bad In Postgres, adding an index non-concurrently locks the table. @@ -331,40 +333,10 @@ ```sh rails g index table column ``` -### Removing an index - -Note: This check is [opt-in](#opt-in-checks). - -#### Bad - -In Postgres, removing an index non-concurrently locks the table for a brief period. - -```ruby -class RemoveSomeIndexFromUsers < ActiveRecord::Migration[6.0] - def change - remove_index :users, :some_column - end -end -``` - -#### Good - -Remove indexes concurrently. - -```ruby -class RemoveSomeIndexFromUsers < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - remove_index :users, column: :some_column, algorithm: :concurrently - end -end -``` - ### Adding a reference #### Bad Rails adds an index non-concurrently to references by default, which is problematic for Postgres. @@ -589,19 +561,15 @@ Note: Since `remove_column` always requires a `safety_assured` block, it’s not possible to add a custom check for `remove_column` operations. ## Opt-in Checks -Some operations rarely cause issues in practice, but can be checked if desired. Enable checks with: +### Removing an index non-concurrently -```ruby -StrongMigrations.enable_check(:remove_index) -``` +Postgres supports removing indexes concurrently, but removing them non-concurrently shouldn’t be an issue for most applications. You can enable this check with: -To start a check only after a specific migration, use: - ```ruby -StrongMigrations.enable_check(:remove_index, start_after: 20170101000000) +StrongMigrations.enable_check(:remove_index) ``` ## Disable Checks Disable specific checks with: