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

Unnecessary SET DEFAULT statement for inherited columns with a default value #20

Open
DAAAAAAAAAAAAAAAAN opened this issue Jan 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@DAAAAAAAAAAAAAAAAN
Copy link
Contributor

Description

The generated migrations will always add a statement for setting the default value of an inherited column (which has a default value set), even though it changes nothing and even does it if a previous migration already includes the statement.

Steps To Reproduce

  1. Create empty folder and go through trek init
  2. Open the model in pgmodeler
  3. Add schema schemaname
  4. Add table schemaname.table1
  5. Add column bla to table1 with some type and some default value
  6. Run trek generate migrationname (important because of bug Failure after creating 2 tables with an inheritance relation #19 )
  7. Add schemaname.table2
  8. Add inheritance relation from table2 to table1
  9. Validate and save
  10. Run trek generate --stdout

Relevant log output

--
create table "schemaname"."table2" (
    "bla" smallint default 1
) inherits ("schemaname"."tablename");

-- Statements generated automatically, please review:
ALTER TABLE schemaname.table2 OWNER TO databaseuser;
ALTER TABLE ONLY schemaname.table2 ALTER COLUMN bla SET DEFAULT 1;

--
@DAAAAAAAAAAAAAAAAN DAAAAAAAAAAAAAAAAN added the bug Something isn't working label Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant