def create_initial_db():
from config import config
from app.infrastructure.mappings import mapping
from app.infrastructure.mappings.mapping import metadata
db = SQLAlchemy()
config = config[os.getenv('FLASK_CONFIG') or 'default']
metadata.create_all(db.engine)
if not os.path.exists(config.SQLALCHEMY_MIGRATE_REPO):
api.create(config.SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(config.SQLALCHEMY_DATABASE_URI, config.SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(config.SQLALCHEMY_DATABASE_URI, config.SQLALCHEMY_MIGRATE_REPO, api.version(config.SQLALCHEMY_MIGRATE_REPO))
评论列表
文章目录