Skip to content

Commit e6207fb

Browse files
committed
don't show the migrations warning if a migrations command is being run
1 parent 8905f66 commit e6207fb

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

piccolo/main.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,36 @@ def main():
8484
continue
8585
cli.register(command, group_name=app_name)
8686

87-
# Show a warning if any migrations haven't been run.
88-
try:
89-
havent_ran_count = run_sync(
90-
CheckMigrationManager(app_name="all").havent_ran_count()
91-
)
92-
if havent_ran_count:
93-
message = (
94-
f"{havent_ran_count} migration hasn't"
95-
if havent_ran_count == 1
96-
else f"{havent_ran_count} migrations haven't"
87+
if "migrations" not in sys.argv:
88+
# Show a warning if any migrations haven't been run.
89+
# Don't run it if it looks like the user is running a migration
90+
# command, as this information is redundant.
91+
92+
try:
93+
havent_ran_count = run_sync(
94+
CheckMigrationManager(app_name="all").havent_ran_count()
9795
)
98-
print(
99-
colored_string(
100-
message=(
101-
"=> {} been run - the app "
102-
"might not behave as expected.\n"
103-
"To check which use:\n"
104-
" piccolo migrations check\n"
105-
"To run all migrations:\n"
106-
" piccolo migrations forwards all\n"
107-
).format(message),
108-
level=Level.high,
96+
if havent_ran_count:
97+
message = (
98+
f"{havent_ran_count} migration hasn't"
99+
if havent_ran_count == 1
100+
else f"{havent_ran_count} migrations haven't"
109101
)
110-
)
111-
except Exception:
112-
pass
102+
print(
103+
colored_string(
104+
message=(
105+
"=> {} been run - the app "
106+
"might not behave as expected.\n"
107+
"To check which use:\n"
108+
" piccolo migrations check\n"
109+
"To run all migrations:\n"
110+
" piccolo migrations forwards all\n"
111+
).format(message),
112+
level=Level.high,
113+
)
114+
)
115+
except Exception:
116+
pass
113117

114118
###########################################################################
115119

0 commit comments

Comments
 (0)