def handle(self, **options):
options['secret_key'] = token_hex(60)
options['template'] = 'project_template'
base_dir, name = super(Command, self).handle(**options)
# Setup Alembic Migrations
alembic_dir = os.path.join(base_dir, name, 'migrations')
cfg = Config(os.path.join(alembic_dir, 'alembic.ini'))
command.init(config=cfg, directory=alembic_dir)
with open(os.path.join(alembic_dir, 'env.py'), 'r') as f:
env_py = f.read()
env_py = env_py.replace('target_metadata = None', METADATA_CODE)
env_py = env_py.replace('config = context.config', SQL_CONNECT_OVERRIDE)
with open(os.path.join(alembic_dir, 'env.py'), 'w') as f:
f.write(env_py)
评论列表
文章目录