pgschema
pgschema copied to clipboard
Primary key using generated column
CREATE TABLE IF NOT EXISTS commit (
id text PRIMARY KEY,
git_repository_id integer NOT NULL REFERENCES git.repository (git_repository_id)
);
Plan after dump && plan without file modifications
ALTER TABLE commit DROP CONSTRAINT commit_git_repository_id_fkey;
ALTER TABLE dependency.commit
ADD CONSTRAINT commit_git_repository_id_fkey FOREIGN KEY (git_repository_id) REFERENCES git.repository (git_repository_id) NOT VALID;
ALTER TABLE dependency.commit VALIDATE CONSTRAINT commit_git_repository_id_fkey;
Could you please describe the workflow in more details?
I just reproduce it on clean pg, it related to generated columns.
CREATE TABLE IF NOT EXISTS git.repository
(
data jsonb NOT NULL,
git_repository_id integer PRIMARY KEY GENERATED ALWAYS AS ( (data ->> 'iid')::integer) STORED
);