Postgres supports creating columns that are generated when the row is inserted, updated.
In my case, I have a property that has its address separated into multiple columns and I want to create a special field that will have the concatenation of all these fields.
I was wondering if AshPostgres has support for that feature.
What I tried so far was creating a specific
statement
statement
to create the field in the migration:
statement :create_normalized_full_address_field do up "alter table properties add column normalized_full_address generated always as (street_name || ' ' || city) stored;" down "alter table properties drop column normalized_full_address;" end
statement :create_normalized_full_address_field do up "alter table properties add column normalized_full_address generated always as (street_name || ' ' || city) stored;" down "alter table properties drop column normalized_full_address;" end
But I don't know how to add that attribute into the resource in a way that will not create it already when generating the migration file.
Also, it would be great to have a way to do it without using a custom statement, but I'm fine with that.
The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.