def run_migrations_offline(): """ Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output. """ db_url = get_db_url() config.set_main_option("sqlalchemy.url", db_url) # TODO: Is this required? context.configure(url=db_url, target_metadata=target_metadata, transactional_ddl=True) with context.begin_transaction(): context.run_migrations(op=alembic_op, tables=tables, tester=get_tester())
from alembic import context from flask import current_app from sqlalchemy import engine_from_config, pool from indico.core.db.sqlalchemy.util.models import import_all_models # Ensure all our models are imported import_all_models() # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config logging.config.fileConfig(config.config_file_name) config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI')) target_metadata = current_app.extensions['migrate'].db.metadata def _include_symbol(tablename, schema): # We ignore plugin tables in migrations if schema and schema.startswith('plugin_'): return False return tablename != 'alembic_version' and not tablename.startswith( 'alembic_version_') def _render_item(type_, obj, autogen_context): if hasattr(obj, 'info') and obj.info.get('alembic_dont_render'): return None func = getattr(obj, 'alembic_render_' + type_, None)
if not current_plugin: raise Exception('Cannot run plugin db migration outside plugin context') # Ensure all our models are imported - XXX is this necessary? if we call configure_db it's not! import_all_models() import_all_models(current_plugin.package_name) # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config logging.config.fileConfig(config.config_file_name) config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI')) target_metadata = current_app.extensions['migrate'].db.metadata # Get rid of the ZODB transaction manager update_session_options(db) plugin_schema = 'plugin_{}'.format(current_plugin.name) version_table = 'alembic_version_plugin_{}'.format(current_plugin.name) def _include_symbol(tablename, schema): # We only include tables in this plugin's schema in migrations return schema == plugin_schema def _render_item(type_, obj, autogen_context):
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import logging.config from alembic import context import sqlalchemy from tuning_box import db config = context.config if config.get_main_option('table_prefix') is None: config.set_main_option('table_prefix', '') if config.config_file_name: logging.config.fileConfig(config.config_file_name) target_metadata = db.db.metadata def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output.
from alembic import context from flask import current_app from ormeasy.common import import_all_modules from sqlalchemy import engine_from_config, pool from iu.orm import Base import_all_modules('iu') # this is the Alembic Config object, which provides # access to the values within the .ini file in use. app_database_config = current_app.config['APP_CONFIG'].get('database', {}) config = context.config config.set_main_option('sqlalchemy.url', app_database_config.get('url')) # Interpret the config file for Python logging. # This line sets up loggers basically. logging.config.fileConfig(config.config_file_name) logger = logging.getLogger('alembic.env') # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata target_metadata = Base.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")
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import logging.config from alembic import context import sqlalchemy #from tuning_box import db config = context.config if config.get_main_option('table_prefix') is None: config.set_main_option('table_prefix', '') if config.config_file_name: logging.config.fileConfig(config.config_file_name) #target_metadata = db.db.metadata target_metadata = None def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the
from alembic import context from flask import current_app from sqlalchemy import engine_from_config, pool # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. logging.config.fileConfig(config.config_file_name) logger = logging.getLogger('alembic.env') config.set_main_option( 'sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI').replace('%', '%%'), ) target_metadata = current_app.extensions['migrate'].db.metadata def _render_item(type_, obj, autogen_context): if hasattr(obj, 'info') and obj.info.get('alembic_dont_render'): return None func = getattr(obj, 'alembic_render_' + type_, None) if func is None: return False return func(autogen_context) def run_migrations_offline(): """Run migrations in 'offline' mode.