pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

Incorrect migration for generated columns

Open grachevko opened this issue 1 year ago • 2 comments

old.sql

CREATE TABLE IF NOT EXISTS merge_request (
    data jsonb NOT NULL
);

new.sql

CREATE TABLE IF NOT EXISTS merge_request(
    data jsonb   NOT NULL,
    iid  integer NOT NULL GENERATED ALWAYS AS ( (data ->> 'iid')::integer ) STORED
);

Expected:

ALTER TABLE merge_request
    ADD COLUMN iid integer NOT NULL GENERATED ALWAYS AS ( (data ->> 'iid')::integer ) STORED;

Actual:

ALTER TABLE merge_request ADD COLUMN iid integer NOT NULL;

grachevko avatar Sep 24 '25 15:09 grachevko

I guess we haven't implemented GENERATED column, I will take a look

tianzhou avatar Sep 24 '25 15:09 tianzhou

I've tried to implement this myself but found it a bit more complex for me

grachevko avatar Sep 24 '25 16:09 grachevko