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

Addition/dropping of inherited columns not handled properly #33

Closed
jmafc opened this issue May 28, 2012 · 0 comments
Closed

Addition/dropping of inherited columns not handled properly #33

jmafc opened this issue May 28, 2012 · 0 comments
Labels

Comments

@jmafc
Copy link
Member

jmafc commented May 28, 2012

Given tables test1 and test2, the latter inheriting from the former:

CREATE TABLE test1 (
    c1 integer NOT NULL,
    c2 text);
CREATE TABLE test2 (
    c3 date) INHERITS (test1);

If we add column c4 to test1, e.g., ALTER TABLE test1 ADD c4 char(5);, even though dbtoyaml flags c4 as inherited in test2, yamltodb generates two ALTER TABLES:

ALTER TABLE test1
    ADD COLUMN c4 character(5);
ALTER TABLE test2
    ADD COLUMN c4 character(5);

which as expected causes an error in Postgres: column "c4" of relation "test2" already exists.

Similarly, if column c2 is dropped from test1, .e.g., ALTER TABLE test1 DROP c2, yamltodb generates two drops:

ALTER TABLE test1 DROP COLUMN c2;
ALTER TABLE test2 DROP COLUMN c2;

Addding a default to the parent table, e.g., ALTER TABLE test1 ALTER c2 SET DEFAULT 'Some text', also causes two ALTER TABLEs to be generated by yamltodb, but PostgreS accepts those (but it's incorrect and inefficient).

@jmafc jmafc closed this as completed in fde6445 Jul 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant