Giter VIP home page Giter VIP logo

Comments (4)

antonio-antuan avatar antonio-antuan commented on June 21, 2024 1

ok found a hook named process_revision_directives, looks like I can customize autogenerated ops. thanks :)

from alembic_utils.

olirice avatar olirice commented on June 21, 2024

currently there is no way to have alembic_utils manage an index on a materialized view

there is some more discussion and a partial implementation over at #46 but for now I'd recommend managing them manually

If you're trying to do something highly consistent, like add a unique index on id to support concurrent refreshes, you could consider adding a hook in env.py to raise an exception if it detects a materialized view with an id column that does not have an associated unique index. If that sounds useful but you're not sure how to do it, lmk and I'll pull a code sample together

from alembic_utils.

antonio-antuan avatar antonio-antuan commented on June 21, 2024

@olirice I would appreciate if you provided a hook example, which can be used with revision --autogenerate. I found a way to make a comparison in env.py, but don't know how to raise an exception after new revision is generated.

from alembic_utils.

phenry2 avatar phenry2 commented on June 21, 2024

Found a way around this by creating a new PGMaterializedViewExtended class which took the indexes that should be included with the MV as a parameter. It then injects create scripts for the indexes into the MV definition to aid with detecting changes. from_database then just pulls the MV, and any indexes relating to the MV and re-creates the definition with both the MV and its indexes. Works nicely on upgrade/downgrade and detects any changes to indexes I've added, remove or changed.

from alembic_utils.

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.