2021-09-15 17:41:45 -07:00
|
|
|
import click
|
2021-10-20 13:01:46 -07:00
|
|
|
|
2021-10-22 06:36:15 -07:00
|
|
|
from redis_om.model.migrations.migrator import Migrator
|
2021-09-15 17:41:45 -07:00
|
|
|
|
|
|
|
|
|
|
|
@click.command()
|
2021-10-22 06:36:15 -07:00
|
|
|
@click.option("--module", default="redis_om")
|
2021-09-15 17:41:45 -07:00
|
|
|
def migrate(module):
|
2021-10-20 13:01:46 -07:00
|
|
|
migrator = Migrator(module)
|
|
|
|
|
2021-09-15 17:41:45 -07:00
|
|
|
if migrator.migrations:
|
|
|
|
print("Pending migrations:")
|
|
|
|
for migration in migrator.migrations:
|
|
|
|
print(migration)
|
2021-10-20 13:01:46 -07:00
|
|
|
|
|
|
|
if input("Run migrations? (y/n) ") == "y":
|
2021-09-15 17:41:45 -07:00
|
|
|
migrator.run()
|