Giter Site home page Giter Site logo

Comments (2)

rkhaotix avatar rkhaotix commented on June 9, 2024

@pematt The original problem is fixed. However, the generated diff still has a semantic problem that I still need to figure out how to solve.

After applying the patch the generate code was:

-- [ Dropped objects ] --
ALTER TABLE test.test DETACH PARTITION test.test_2024;
-- ddl-end --
ALTER TABLE test.test DETACH PARTITION test.test_2025;
-- ddl-end --


-- [ Created objects ] --
ALTER TABLE test.test ADD COLUMN new_column smallint;
-- ddl-end --
ALTER TABLE test.test ATTACH PARTITION test.test_2024 FOR VALUES FROM ('2024-01-01') TO ('2025-01-01');
-- ddl-end --
ALTER TABLE test.test ATTACH PARTITION test.test_2025 FOR VALUES FROM ('2025-01-01') TO ('2026-01-01');
-- ddl-end --

But if you run the diff above from pgModeler it'll break on the first ALTER TABLE ... ATTACH that's because since the partitions were detached in the first lines of the script we have to add the new columns on all partitions which is not happening according to the diff code.

The lines where ATTACH and DETACH appear are false-positive codes because they are only generated when the partitioning bounding expressions change. It took me a while to figure out what was happening... but pgModeler compares the partitioning bounding expression from the original model and the one imported by the diff process.

It turns out that PostgreSQL converts FOR VALUES FROM ('2025-01-01') TO ('2026-01-01'); to FOR VALUES FROM ('2025-01-01 00:00:00-03') TO ('2026-01-01 00:00:00-03');. Semantically, they are all the same, but for pgModeler not, and that is causing pgModeler to create the code to detach and (re)attach the partitions. The workaround for this issue is to add the hour (and eventually the timezone) to the partitions' bounding expressions in your database model so the mentioned code stops being generated. Your example, unfortunately, hits one of the limitations of pgModeler: the semantical comparison which isn't available at the moment! :(

from pgmodeler.

pematt avatar pematt commented on June 9, 2024

Ok I will do that. Thank you very much for the detailed explanation how to solve it!

from pgmodeler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.