Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/core/models.py
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | def initialize(db_engine, drop_tables=False, **kwargs): | ||||
Typically called from the lister's initialization hook. | Typically called from the lister's initialization hook. | ||||
Args: | Args: | ||||
models (list): list of SQLAlchemy tables/models to drop/create. | models (list): list of SQLAlchemy tables/models to drop/create. | ||||
db_engine (): the SQLAlchemy DB engine. | db_engine (): the SQLAlchemy DB engine. | ||||
drop_tables (bool): if True, tables will be dropped before | drop_tables (bool): if True, tables will be dropped before | ||||
(re)creating them. | (re)creating them. | ||||
""" | """ | ||||
if drop_tables: | if drop_tables: | ||||
logger.info('Dropping tables') | logger.info('Dropping tables') | ||||
SQLBase.metadata.drop_all(db_engine, checkfirst=True) | SQLBase.metadata.drop_all(db_engine, checkfirst=True) | ||||
logger.info('Creating tables') | logger.info('Creating tables') | ||||
SQLBase.metadata.create_all(db_engine, checkfirst=True) | SQLBase.metadata.create_all(db_engine, checkfirst=True) |