Comments (5)
Quite right.
To use the latest library version i had to implement two step migrations:
# env.py
...
# I will register replaceable entities only if x_argument run_replaceable == "true"
if context.get_x_argument(as_dictionary=True).get("run_replaceable") == 'true':
register_entities(replaceable_entities_list)
def run_table_migrations():
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
run_table_migrations()
and then in the automigration script:
# migrate.sh
alembic -x run_replaceable="false" revision --autogenerate
alembic upgrade head
alembic -x run_replaceable="true" revision --autogenerate
alembic upgrade head
from alembic_utils.
I have the same Issue. In env.py
I create my views based on metadata with
from alembic_utils.replaceable_entity import register_entities
views = genereate_views_from_metadata()
register_entities(views)
I have no connection in env.py
so I cannot check in genereate_views_from_metadata
if my dependent tables are already created in the database or not.
from alembic_utils.
I have no connection in env.py so I cannot check in genereate_views_from_metadata if my dependent tables are already created in the database or not.
For --autogenerate
support the view's table dependencies must have been created in a prior migration. So long as that is the case, you should not need a connection to the database in env.py
but if you do need a connection for some reason, you can connect to the DB from anywhere the same way alembic does
# env.py
from sqlalchemy import create_engine
url = config.get_main_option("sqlalchemy.url")
engine = create_engine(url)
from alembic_utils.
I have the same issues and downgrading alembic-utils to "0.2.15" solved the problem.
from alembic_utils.
0.2.15 is significantly out of date. I wouldn't recommend going back that far
This was never supported by alembic_utils
so if its incidentally working on an old release there's no guarantee that it'll be stable
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.