Skip to content

Commit 7c0ba1b

Browse files
committed
modified _create_new_migration to return info about the created file
This will be useful for testing purposes.
1 parent bf04183 commit 7c0ba1b

File tree

1 file changed

+15
-1
lines changed
  • piccolo/apps/migrations/commands

1 file changed

+15
-1
lines changed

piccolo/apps/migrations/commands/new.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import annotations
2+
from dataclasses import dataclass
23
import datetime
34
from itertools import chain
45
import os
@@ -52,7 +53,16 @@ def _create_migrations_folder(migrations_path: str) -> bool:
5253
return True
5354

5455

55-
async def _create_new_migration(app_config: AppConfig, auto=False) -> None:
56+
@dataclass
57+
class NewMigrationMeta:
58+
migration_id: str
59+
migration_filename: str
60+
migration_path: str
61+
62+
63+
async def _create_new_migration(
64+
app_config: AppConfig, auto=False
65+
) -> NewMigrationMeta:
5666
"""
5767
Creates a new migration file on disk.
5868
"""
@@ -105,6 +115,10 @@ async def _create_new_migration(app_config: AppConfig, auto=False) -> None:
105115
with open(path, "w") as f:
106116
f.write(file_contents)
107117

118+
return NewMigrationMeta(
119+
migration_id=_id, migration_filename=filename, migration_path=path
120+
)
121+
108122

109123
###############################################################################
110124

0 commit comments

Comments
 (0)