alter table("posts") do
add :identity, :integer, generated: "BY DEFAULT AS IDENTITY" # Postgres generated identity column
add :generated_psql, :string, generated: "ALWAYS AS (id::text) STORED" # Postgres calculated column
add :generated_other, :string, generated: "CAST(id AS char)" # MySQL and TDS calculated column
end
There are 2 types of generated columns but postgres only supports stored which calculates all the values during migration and locks the table. This is not safe on an existing table.
I hit this today: ecto allows to add a generated column.
There are 2 types of generated columns but postgres only supports stored which calculates all the values during migration and locks the table. This is not safe on an existing table.