def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. Runs for both wikimetrics and wikimetrics_testing database. """ config = db.config engine = get_engine(config) migrations = [(engine, target_metadata)] if db.config['DEBUG'] is True: test_config = setup_testing_config(deepcopy(config)) test_engine = get_engine(test_config) test_metadata = db.WikimetricsBase.metadata migrations.append((test_engine, test_metadata)) for eng, meta_data in migrations: connection = eng.connect() context.configure(connection=connection, target_metadata=meta_data) print("Running migration for " + eng.url.database) try: with context.begin_transaction(): context.run_migrations() finally: connection.close()
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. Runs for wikimetrics, wikimetrics_testing and centralauth_testing databases. """ config = db.config engine = get_engine(config) migrations = [(engine, target_metadata)] if db.config['DEBUG'] is True: test_config = setup_testing_config(deepcopy(config)) # add wikimetrics_testing migrations test_engine = get_engine(test_config) test_metadata = db.WikimetricsBase.metadata migrations.append((test_engine, test_metadata)) # NOTE: centralauth and mediawiki schemas should be maintained # manually and not managed with alembic, as they are not schemas # we own for eng, meta_data in migrations: connection = eng.connect() context.configure(connection=connection, target_metadata=meta_data) print("Running migration for " + eng.url.database) try: with context.begin_transaction(): context.run_migrations() finally: connection.close()
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. Runs for wikimetrics, wikimetrics_testing and centralauth_testing databases. """ config = db.config engine = get_engine(config) migrations = [(engine, target_metadata)] if db.config['DEBUG'] is True: test_config = setup_testing_config(deepcopy(config)) # add wikimetrics_testing migrations test_engine = get_engine(test_config) test_metadata = db.WikimetricsBase.metadata migrations.append((test_engine, test_metadata)) # NOTE: centralauth and mediawiki schemas should be maintained # manually and not managed with alembic, as they are not schemas # we own for eng, meta_data in migrations: connection = eng.connect() context.configure(connection=connection, target_metadata=meta_data) print("Running migration for " + eng.url.database) try: with context.begin_transaction(): context.run_migrations() finally: connection.close()
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ import copy config = copy.copy(db.config) engine = get_engine(config) test_config = setup_testing_config(config) test_engine = get_engine(test_config) test_metadata = db.WikimetricsBase.metadata for name, eng, meta_data in [(test_config['WIKIMETRICS_ENGINE_URL'], test_engine, test_metadata), (config['WIKIMETRICS_ENGINE_URL'], engine, target_metadata)]: connection = eng.connect() context.configure(connection=connection, target_metadata=meta_data) print "Running migration for " + name try: with context.begin_transaction(): context.run_migrations() finally: connection.close()
def setUpTestingDB(): """ Set global testing variables. By convention testing dbs are development dbs with sufix "_testing" we change url connection strings so tests run on testing databases Note that wikimetrics user already exists, puppet has created it. """ # NOTE: need to import these inline, otherwise they might match the # nosetests regular expression and run as tests from wikimetrics.configurables import app, db, setup_testing_config # Set TESTING to true so we can know to not check CSRF # TODO we need a global config object app.config['TESTING'] = True db.config = setup_testing_config(db.config)
def setUpTestingDB(): """ Set global testing variables. By convention testing dbs are development dbs with sufix "_testing" we change url connection strings so tests run on testing databases Note that wikimetrics user already exists, puppet has created it. """ # NOTE: need to import these inline, otherwise they might match the # nosetests regular expression and run as tests from wikimetrics.configurables import app, db, setup_testing_config # Set TESTING to true so we can know to not check CSRF # TODO we need a global config object app.config['TESTING'] = True db.config = setup_testing_config(db.config)