2021-09-16 02:41:45 +02:00
|
|
|
import click
|
2021-10-20 22:01:46 +02:00
|
|
|
|
2021-11-10 00:59:10 +01:00
|
|
|
from aredis_om.model.migrations.migrator import Migrator
|
2021-09-16 02:41:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
@click.command()
|
2021-11-10 00:59:10 +01:00
|
|
|
@click.option("--module", default="aredis_om")
|
2023-07-11 13:06:37 +02:00
|
|
|
def migrate(module: str):
|
2021-10-20 22:01:46 +02:00
|
|
|
migrator = Migrator(module)
|
2021-11-25 03:12:27 +01:00
|
|
|
migrator.detect_migrations()
|
2021-10-20 22:01:46 +02:00
|
|
|
|
2021-09-16 02:41:45 +02:00
|
|
|
if migrator.migrations:
|
|
|
|
print("Pending migrations:")
|
|
|
|
for migration in migrator.migrations:
|
|
|
|
print(migration)
|
2021-10-20 22:01:46 +02:00
|
|
|
|
|
|
|
if input("Run migrations? (y/n) ") == "y":
|
2021-09-16 02:41:45 +02:00
|
|
|
migrator.run()
|