Generated columns
From the collection Ecto and Postgresql

columns
generated
postgres
postgresql

Generated columns

You can show this QR Code to a friend or ask them to scan directly on your screen!

Thanks for sharing! 🫶

The url for this was also copied to your clipboard!
https://www.postgresql.org/docs/current/ddl-generated-columns.html
https://fluca1978.github.io/2020/03/02/PostgreSQLGeneratedColumns_part2.html

ALTER TABLE sanctions_lists
    ADD COLUMN soundex_code varchar
    GENERATED ALWAYS
    AS (
        CASE
            WHEN full_name is NULL THEN soundex('XXXXXXX')
            ELSE soundex(full_name)
        END
    ) STORED
See more from etori.sangiacomo