Giter VIP home page Giter VIP logo

Comments (3)

olirice avatar olirice commented on May 26, 2024 2

Thought about this some more

Support for CREATE EXTENSION and DROP EXTENSION is probably the 99% use case. Additional support for ALTER statements could be added in the future in a backwards compatible way so there's no need to get hung up on that now

alembic_utils.pg_extension.PGExtension has been added and is available on pypi in alembic_utils>=0.7.0

from alembic_utils.

olirice avatar olirice commented on May 26, 2024

Its a little trickier than you might think depending on how much functionality that class would have

Support for creating a dropping an extension would be easy

CREATE EXTENSION [ IF NOT EXISTS ] extension_name
    [ WITH ] [ SCHEMA schema_name ]
             [ VERSION version ]
             [ FROM old_version ]

and

DROP EXTENSION [ IF EXISTS ] extension_name [, ...] [ CASCADE | RESTRICT ]

with comparisons made through pg_available_extensions

But there are several alter commands and not all of them are reversible (to produce the down migration).

For example

ALTER EXTENSION name UPDATE [ TO new_version ]

there is no equivalent downgrade statement because postgres extensions aren't expected to implement down migrations for the sql bindings. See the migration upgrade files in the pgsql-http extension in the form http--<old_version>--<new_version>.sql.

Most of those alter statements could likely be ignored/unsupported but ALTER EXTENSION name SET SCHEMA new_schema would need to work vs dropping and recreating the extension if the schema associated with PGExtension changed.


The ReplaceableEntity structure but that class is best suited for entities that implement CREATE OR REPLACE. I have broken that rule before with some success but its never fun.

With that context, if you'd like to open a PR that implements the minimal CREATE/DROP/SET SCHEMA operations with test coverage I'm definitely interested in the feature.

I'll leave this open to track future discussion wrt extensions

from alembic_utils.

tdamsma avatar tdamsma commented on May 26, 2024

That was quick, many thanks!

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.