Comments (3)
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.
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.
That was quick, many thanks!
from alembic_utils.
Related Issues (20)
- [Question] Using Alembic Utils without SQL Alchemy models HOT 3
- [QUESTION] compatibility with sqlalchemy_utils.functions.create_database HOT 2
- Compatibility with SQLAlchemy 2.0 HOT 4
- How to add a function with an " text[] default array['text', 'text2']"? HOT 1
- PGExtension replace `create` with `create if not exists` HOT 4
- Must be owner of materialized view mat_view_name HOT 2
- Alembic autogenerate broken for 'internal' PG functions HOT 5
- INFO: Transaction approach incompatible with MySQL
- alembic check broken - diff cannot be rendered HOT 1
- Materialized view change detection fails if upstream view has changed HOT 6
- DropOp dependency ordering when dropping multiple associated entities HOT 4
- Publishing next release HOT 1
- remove duplicate "instance" ref
- Duplicated ReplaceableEntity on every migration HOT 5
- PGFunction detection of plpgsql doesn't account for language definition wrapped in quotes HOT 1
- gracefully handle when a migrator needs to modify a column that a view depends on HOT 8
- Creating an ORM Table mapping on a view will generate a migration to create a table HOT 4
- [Question] How to add a unique index to definition for PGMaterializedView HOT 4
- Colon character escaped unnecessarily in view autogeneration HOT 4
- Downgrade does not reflect old definition
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alembic_utils.