diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-01-06 21:54:31 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-01-06 21:54:31 +0100 |
commit | e4042c4b31267670e52a7d3f8154d9aaf5651ffa (patch) | |
tree | b9b40806270c0482060ff4ec383478960e03013b /src/migrations/env.py | |
parent | Minor edit to the /feed page (template). (diff) | |
download | newspipe-e4042c4b31267670e52a7d3f8154d9aaf5651ffa.tar.gz newspipe-e4042c4b31267670e52a7d3f8154d9aaf5651ffa.tar.bz2 newspipe-e4042c4b31267670e52a7d3f8154d9aaf5651ffa.zip |
it seemms that alembic do not find the models
Diffstat (limited to 'src/migrations/env.py')
-rw-r--r-- | src/migrations/env.py | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/migrations/env.py b/src/migrations/env.py index 70961ce2..355c8dd1 100644 --- a/src/migrations/env.py +++ b/src/migrations/env.py @@ -9,7 +9,7 @@ config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. -fileConfig(config.config_file_name) +fileConfig("./alembic.ini") # add your model's MetaData object here # for 'autogenerate' support @@ -19,6 +19,7 @@ from flask import current_app config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI')) target_metadata = current_app.extensions['migrate'].db.metadata + # other values from the config, defined by the needs of env.py, # can be acquired: # my_important_option = config.get_main_option("my_important_option") @@ -49,25 +50,21 @@ def run_migrations_online(): and associate a connection with the context. """ - engine = engine_from_config( - config.get_section(config.config_ini_section), - prefix='sqlalchemy.', - poolclass=pool.NullPool) - - connection = engine.connect() - context.configure( - connection=connection, - target_metadata=target_metadata - ) - - try: + 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() - finally: - connection.close() if context.is_offline_mode(): run_migrations_offline() else: run_migrations_online() - |