def sync(): """Synchronize database with latest schema and persistence data. Idempotent function takes necessary steps to build tables, migrate schema and run `seed`. Safe to run on existing or brand new databases. To re/create the database, [delete and] create within the DBMS itself, then invoke this function. """ if not db.engine.dialect.has_table(db.engine.connect(), 'alembic_version'): db.create_all() stamp_db() upgrade_db() seed()
def sync(): """Synchronize database with latest schema and persistence data. Idempotent function takes necessary steps to build tables, migrate schema and run `seed`. Safe to run on existing or brand new databases. To re/create the database, [delete and] create within the DBMS itself, then invoke this function. """ if not db.engine.dialect.has_table(db.engine.connect(), 'alembic_version'): db.create_all() stamp_db() flush_cache() upgrade_db() seed()
def setUp(self): """Reset all tables before testing.""" db.drop_all() # clean up from previous tests db.create_all() with SessionScope(db): # concepts take forever, only load the quick ones. # add directly (via self.add_concepts()) if test needs them add_static_concepts(only_quick=True) add_static_interventions() add_static_organization() add_static_relationships() add_static_roles() db.session.commit() self.init_data() self.client = self.__app.test_client() # removed unwanted config items if present for item in ('REQUIRED_CORE_DATA', 'LOCALIZED_AFFILIATE_ORG'): if item in self.client.application.config: del self.client.application.config[item] # reload coredata config configure_coredata(self.client.application)