README.md in strong_migrations-1.4.4 vs README.md in strong_migrations-1.5.0

- old
+ new

@@ -60,10 +60,11 @@ Potentially dangerous operations: - [removing a column](#removing-a-column) - [adding a column with a default value](#adding-a-column-with-a-default-value) - [backfilling data](#backfilling-data) +- [adding a stored generated column](#adding-a-stored-generated-column) [unreleased] - [changing the type of a column](#changing-the-type-of-a-column) - [renaming a column](#renaming-a-column) - [renaming a table](#renaming-a-table) - [creating a table with the force option](#creating-a-table-with-the-force-option) - [adding a check constraint](#adding-a-check-constraint) @@ -188,9 +189,27 @@ sleep(0.01) # throttle end end end ``` + +### Adding a stored generated column + +#### Bad + +Adding a stored generated column causes the entire table to be rewritten. During this time, reads and writes are blocked in Postgres, and writes are blocked in MySQL and MariaDB. + +```ruby +class AddSomeColumnToUsers < ActiveRecord::Migration[7.0] + def change + add_column :users, :some_column, :virtual, type: :string, as: "...", stored: true + end +end +``` + +#### Good + +Add a non-generated column and use callbacks or triggers instead (or a virtual generated column with MySQL and MariaDB). ### Changing the type of a column #### Bad