Skip to content

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

@DAAAAAAAAAAAAAAAAN

Description

@DAAAAAAAAAAAAAAAAN

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;

--

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions