Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_check_column_generated_stored #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dkuku
Copy link

@dkuku dkuku commented Sep 26, 2024

I hit this today:
ecto allows to add a generated column.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant