Skip to content

Commit ac8ec32

Browse files
committed
Merge branch 'master' into timestamptz_column
2 parents 321440e + 653fcd9 commit ac8ec32

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changes
22
=======
33

4+
0.15.1
5+
------
6+
Changing the status code when creating a migration, and no changes were
7+
detected. It now returns a status code of 0, so it doesn't fail build scripts.
8+
49
0.15.0
510
------
611
Added ``Bytea`` / ``Blob`` column type.

piccolo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__VERSION__ = "0.15.0"
1+
__VERSION__ = "0.15.1"

piccolo/apps/migrations/commands/new.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ async def _create_new_migration(app_config: AppConfig, auto=False) -> None:
7575
)
7676

7777
if sum([len(i.statements) for i in alter_statements]) == 0:
78-
sys.exit("No changes detected - exiting.")
78+
print("No changes detected - exiting.")
79+
sys.exit(0)
7980

8081
file_contents = render_template(
8182
migration_id=_id,

tests/apps/migrations/commands/test_new.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import os
22
import shutil
33
from unittest import TestCase
4+
from unittest.mock import call, patch, MagicMock
45

5-
from piccolo.conf.apps import AppConfig
66
from piccolo.apps.migrations.commands.new import (
77
_create_new_migration,
88
BaseMigrationManager,
99
new,
1010
)
11+
from piccolo.conf.apps import AppConfig
1112
from piccolo.utils.sync import run_sync
1213

1314
from tests.base import postgres_only
@@ -41,13 +42,16 @@ def test_create_new_migration(self):
4142
self.assertTrue(len(migration_modules.keys()) == 1)
4243

4344
@postgres_only
44-
def test_new_command(self):
45+
@patch("piccolo.apps.migrations.commands.new.print")
46+
def test_new_command(self, print_: MagicMock):
4547
"""
4648
Call the command, when no migration changes are needed.
4749
"""
4850
with self.assertRaises(SystemExit) as manager:
4951
run_sync(new(app_name="example_app", auto=True))
5052

51-
self.assertEqual(
52-
manager.exception.__str__(), "No changes detected - exiting."
53+
self.assertEqual(manager.exception.code, 0)
54+
55+
self.assertTrue(
56+
print_.mock_calls[-1] == call("No changes detected - exiting.")
5357
)

0 commit comments

Comments
 (0)