def db_create(): '''Create the db''' db.create_all() # then, load the Alembic configuration and generate the # version table, "stamping" it with the most recent rev: alembic_cfg = Config("alembic.ini") command.stamp(alembic_cfg,"head")
def db_create(): '''Create the db''' with app.app_context(): db.create_all() # then, load the Alembic configuration and generate the # version table, "stamping" it with the most recent rev: setup_alembic_config() # finally, add a minimum set of categories: Volunteer Thinking, Volunteer Sensing, Published and Draft categories = [] categories.append(Category(name="House Coalition", short_name='housecoalition', description="Members of the House of Representatives in the Liberal and National Parties", id=0)) categories.append(Category(name="House Labor", short_name='houselabor', description="Members of the House of Representatives in the Labor Party", id=1)) categories.append(Category(name="Senate Coalition", short_name='senatecoalition', description="Members of the Senate in the Liberal and National Parties", id=2)) categories.append(Category(name="Senate Labor", short_name='senatelabor', description="Members of the Senate in the Labor Party", id=3)) categories.append(Category(name="Crossbench", short_name='crossbench', description="Crossbenchers in both the House of Representatives and the Senate", id=4)) db.session.add_all(categories) db.session.commit()
def db_rebuild(): '''Rebuild the db''' db.drop_all() db.create_all() # then, load the Alembic configuration and generate the # version table, "stamping" it with the most recent rev: setup_alembic_config()
def rebuild_db(): # See this SQLAlchemy recipe: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything inspector = reflection.Inspector.from_engine(db.engine) # gather all data first before dropping anything. # some DBs lock after things have been dropped in # a transaction. metadata = MetaData() tbs = [] all_fks = [] for table_name in inspector.get_table_names(): fks = [] for fk in inspector.get_foreign_keys(table_name): if not fk['name']: continue fks.append(ForeignKeyConstraint((), (), name=fk['name'])) t = Table(table_name, metadata, *fks) tbs.append(t) all_fks.extend(fks) for fkc in all_fks: db.engine.execute(DropConstraint(fkc)) for table in tbs: db.engine.execute(DropTable(table)) db.session.commit() db.create_all()
def rebuild_db(): # See this SQLAlchemy recipe: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything inspector = reflection.Inspector.from_engine(db.engine) # gather all data first before dropping anything. # some DBs lock after things have been dropped in # a transaction. metadata = MetaData() tbs = [] all_fks = [] for table_name in inspector.get_table_names(): fks = [] for fk in inspector.get_foreign_keys(table_name): if not fk['name']: # pragma: no cover continue fks.append( ForeignKeyConstraint((),(),name=fk['name']) ) t = Table(table_name,metadata,*fks) tbs.append(t) all_fks.extend(fks) for fkc in all_fks: db.engine.execute(DropConstraint(fkc)) for table in tbs: db.engine.execute(DropTable(table)) db.session.commit() db.create_all()
def db_create(): '''Create the db''' with app.app_context(): db.create_all() # then, load the Alembic configuration and generate the # version table, "stamping" it with the most recent rev: setup_alembic_config() categories = [] categories.append( Category(name="Collection", short_name='collection', description='Projects for data collection')) db.session.add_all(categories) db.session.commit()
def db_create(): '''Create the db''' db.create_all() # then, load the Alembic configuration and generate the # version table, "stamping" it with the most recent rev: setup_alembic_config() # finally, add a minimum set of categories: Volunteer Thinking, Volunteer Sensing, Published and Draft categories = [] categories.append(model.Category(name="Thinking", short_name='thinking', description='Volunteer Thinking apps')) categories.append(model.Category(name="Volunteer Sensing", short_name='sensing', description='Volunteer Sensing apps')) db.session.add_all(categories) db.session.commit()
def db_create(): '''Create the db''' with app.app_context(): db.create_all() # then, load the Alembic configuration and generate the # version table, "stamping" it with the most recent rev: setup_alembic_config() # finally, add a minimum set of categories: Volunteer Thinking, Volunteer Sensing, Published and Draft categories = [] categories.append(Category(name="Thinking", short_name='thinking', description='Volunteer Thinking projects')) categories.append(Category(name="Volunteer Sensing", short_name='sensing', description='Volunteer Sensing projects')) db.session.add_all(categories) db.session.commit()
def setUp(self): super(TestUserAPI, self).setUp() with self.flask_app.app_context(): db.create_all() self.redis_flushall()
def rebuild_db(): """Rebuild the DB.""" delete_indexes() delete_materialized_views() db.drop_all() db.create_all()
def rebuild_db(): db.drop_all() db.create_all()
def rebuild_db(): """Rebuild the DB.""" delete_materialized_views() db.drop_all() db.create_all()
def rebuild_db(): """Rebuild the DB.""" db.drop_all() db.create_all()
"""Initial database configuration. Note: This file does roughly the same as running ``python cli.py db_create``, but does't require reconfiguring the connection credentials for alembic """ from pybossa.core import create_app, db from pybossa.model.category import Category with create_app(run_as_server=False).app_context(): category = Category(name="Main", short_name="main", description="") db.create_all() if not db.session.query(Category).count(): db.session.add(category) db.session.commit()