File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed
piccolo/apps/migrations/commands Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change 1- import asyncio
2-
31from piccolo .apps .migrations .auto import MigrationManager
42from piccolo .apps .migrations .tables import Migration
3+ from piccolo .utils .sync import run_sync
54from .base import BaseMigrationManager
65
76
@@ -69,12 +68,10 @@ def run(self):
6968 for migration_id in reversed_migration_ids :
7069 print (f"Reversing { migration_id } " )
7170 migration_module = migration_modules [migration_id ]
72- response = asyncio .run (
73- migration_module .forwards ()
74- ) # type: ignore
71+ response = run_sync (migration_module .forwards ())
7572
7673 if isinstance (response , MigrationManager ):
77- asyncio . run (response .run_backwards ())
74+ run_sync (response .run_backwards ())
7875
7976 Migration .delete ().where (
8077 Migration .name == migration_id
Original file line number Diff line number Diff line change 11from __future__ import annotations
2- import asyncio
32import importlib
43import os
54import sys
1312from piccolo .apps .migrations .auto .diffable_table import DiffableTable
1413from piccolo .apps .migrations .auto .schema_snapshot import SchemaSnapshot
1514from piccolo .apps .migrations .tables import Migration
15+ from piccolo .utils .sync import run_sync
1616
1717
1818class BaseMigrationManager (Finder ):
@@ -85,7 +85,7 @@ def get_migration_managers(
8585 ] = self .get_migration_modules (migrations_folder )
8686
8787 for _ , migration_module in migration_modules .items ():
88- response = asyncio . run (migration_module .forwards ())
88+ response = run_sync (migration_module .forwards ())
8989 if isinstance (response , MigrationManager ):
9090 if max_migration_id :
9191 if response .migration_id == max_migration_id :
Original file line number Diff line number Diff line change 11from __future__ import annotations
2- import asyncio
32import sys
43import typing as t
54
87from piccolo .apps .migrations .tables import Migration
98from piccolo .apps .migrations .auto import MigrationManager
109from piccolo .conf .apps import MigrationModule
10+ from piccolo .utils .sync import run_sync
1111
1212
1313class ForwardsMigrationManager (BaseMigrationManager ):
@@ -60,10 +60,10 @@ def run_migrations(self, app_config: AppConfig) -> None:
6060 print (f"Faked { _id } " )
6161 else :
6262 migration_module = migration_modules [_id ]
63- response = asyncio . run (migration_module .forwards ())
63+ response = run_sync (migration_module .forwards ())
6464
6565 if isinstance (response , MigrationManager ):
66- asyncio . run (response .run ())
66+ run_sync (response .run ())
6767
6868 print (f"Ran { _id } " )
6969
You can’t perform that action at this time.
0 commit comments