Coder Social home page Coder Social logo

Comments (4)

olirice avatar olirice commented on June 18, 2024

The behavior your seeing is related to not doing dependency order resolution for the alembic DropOp

When resolution order is a problem the best bet is to break the migration down into smaller chunks:

For example, you could

  • drop trigger A
  • autogen migration
  • drop function A
  • autogen migration
  • create new function B and trigger B
  • autogen migration

alternatively, you could continue dropping both at the same time and manually re-order the drop_entity calls in the autogen'ed migration


Possible approaches to solving this upstream (if you'd like to submit a PR would be to update here

# No match was found locally
# If the entity passes the filters,
# we should create a DropOp
upgrade_ops.ops.append(DropOp(db_entity))
logger.info(
"Detected DropOp op for %s %s",
db_entity.__class__.__name__,
db_entity.identity,
)

To

  1. Order the drops so that PGTrigger is always first (this would solve you problem but not all problems)
  2. Collect a list of the entities planned for dropping and then do drop order resolution before appending to upgrade_ops equivalent to
    def solve_resolution_order(sess: Session, entities):

where either implementation would need tests like this one https://github.com/olirice/alembic_utils/blob/master/src/test/test_depends.py

from alembic_utils.

tauseef13bok avatar tauseef13bok commented on June 18, 2024

Hi .I created a fork , to solve the dependency ordering . My fork supports ordering of nested dependencies for both create and drop operation. Could you have a look?

from alembic_utils.

olirice avatar olirice commented on June 18, 2024

If you could open a PR an annotate the changes I'd be happy to take a look!

from alembic_utils.

tauseef13bok avatar tauseef13bok commented on June 18, 2024

Sure. done.

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.