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

psqldef generates a migration error when adding a foreign key to an existing table with a schema #194

Closed
tango238 opened this issue Jan 27, 2022 · 1 comment

Comments

@tango238
Copy link

Problem

When I added to a foreign key to an existing table, psqldef generated migration error.

Input SQL

  1. Create tables.
CREATE TABLE a.b
(
    "id" serial PRIMARY KEY
);

CREATE TABLE c.d
(
    "id" serial PRIMARY KEY
);
  1. Edit schema.sql and add a foreign key to an existing table.
CREATE TABLE c.d
(
    "id" serial PRIMARY KEY,
    CONSTRAINT d_id_fkey FOREIGN KEY (id) REFERENCES "a"."b" (id)
);

Current output

-- dry run --
ALTER TABLE "c"."d" ADD CONSTRAINT "d_id_fkey" FOREIGN KEY ("id") REFERENCES "b" ("id");

Expected output

ALTER TABLE "c"."d" ADD CONSTRAINT "d_id_fkey" FOREIGN KEY ("id") REFERENCES "a"."b" ("id");
@k0kubun
Copy link
Collaborator

k0kubun commented Jan 28, 2022

Fixed in v0.11.31.

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

No branches or pull requests

2 participants