Comments (2)
If I follow, the error is occurring while trying to autogenerated a new migration, not during deployment, correct?
Materialized views allows arbitrary SQL in their definitions, which is different from the entities alembic manages. To account for that, the diffing during autogenerate uses a separate workflow. When you create a materialized view in postgres it stores the underlying query. That query is parsed and reformatted so your local text blob in your python project no longer matches the text that is stored in postgres. That makes it difficult to determine if the definition has changed during --autogenerate
The way alembic_utils checks to see if the definition of a materialized view has changed is to:
- look at the mat views current definition in the database
and then, in a transaction: - drop the mat view
- recreate the mat view from the local definition
- check if the definition in the db is different than what we started with
- roll back the transaction
The error your seeing is occurring at step 2 while alembic_utils is figuring out which (if any) of your local database entities have changed.
A solution to get you unblocked locally would be to manually execute
alter materialized view <mat view schema>.<mat view name> owner to <local migration role name>
to re-align the materialized view's owner to the role that produces the autogenerated migrations, but that shouldn't be necessary
Are you aware of any reason why the role name that is locally producing the migrations would differ from the role that applied the migrations to that local instance?
For example, spinning up your local development database from a dump of production where the role names are different would cause this
from alembic_utils.
Thank you for the explanation!
From your questions at the end I understand what I am doing wrong. You see, I am not connecting to a local development database, but running the alembic revision
command while connecting directly to a hosted staging DB.
Because I was not aware of any sort of transaction actually being made I believed it to be a no-impact process and as such not needing a local dev DB (not best practices but hey :) ).
In the end what is happening is exactly what you described, the role that applies the migrations in staging is setup similarly to the one i mentioned on the original issue with a k8s job, so the role that applies the migration (remotely) is indeed different than the one that creates the migrations locally.
Guess I'll have to setup some best practices!
Thanks again!
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 3
- PGExtension replace `create` with `create if not exists` HOT 4
- 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
- alembic_utils does not work with Redshift Dialect. HOT 1
- Adapting simulate_entities() to use .begin() instead of .begin_nested() HOT 1
- Extremely slow HOT 3
- connection was closed in the middle of operation HOT 2
- Unexpected white space inclusion in signature (Pg error: function ... does not exist) HOT 1
- Is it possible to create PGTrigger in all the table by expanding declarative_base? HOT 1
- 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.