redis-om-python/aredis_om/model/cli/migrate.py
2023-07-11 14:06:37 +03:00

19 lines
448 B
Python

import click
from aredis_om.model.migrations.migrator import Migrator
@click.command()
@click.option("--module", default="aredis_om")
def migrate(module: str):
migrator = Migrator(module)
migrator.detect_migrations()
if migrator.migrations:
print("Pending migrations:")
for migration in migrator.migrations:
print(migration)
if input("Run migrations? (y/n) ") == "y":
migrator.run()