|
6 | 6 | from unittest import TestCase |
7 | 7 |
|
8 | 8 | from piccolo.conf.apps import AppConfig |
9 | | -from piccolo.columns.column_types import Varchar |
| 9 | +from piccolo.columns.column_types import Integer, Varchar |
10 | 10 | from piccolo.apps.migrations.commands.new import ( |
11 | 11 | _create_new_migration, |
12 | 12 | _create_migrations_folder, |
@@ -61,10 +61,42 @@ def _test_migrations(self, table_classes: t.List[t.Type[Table]]): |
61 | 61 |
|
62 | 62 | # TODO - check the migrations ran correctly |
63 | 63 |
|
64 | | - def test_add_column(self): |
65 | | - table_1 = create_table_class("MyTable") |
66 | | - table_2 = create_table_class( |
67 | | - "MyTable", class_members={"name": Varchar()} |
| 64 | + def test_add_varchar_column(self): |
| 65 | + self._test_migrations( |
| 66 | + table_classes=[ |
| 67 | + create_table_class("MyTable"), |
| 68 | + create_table_class( |
| 69 | + "MyTable", class_members={"name": Varchar()} |
| 70 | + ), |
| 71 | + ] |
68 | 72 | ) |
69 | 73 |
|
70 | | - self._test_migrations(table_classes=[table_1, table_2]) |
| 74 | + def test_remove_varchar_column(self): |
| 75 | + self._test_migrations( |
| 76 | + table_classes=[ |
| 77 | + create_table_class( |
| 78 | + "MyTable", class_members={"name": Varchar()} |
| 79 | + ), |
| 80 | + create_table_class("MyTable"), |
| 81 | + ] |
| 82 | + ) |
| 83 | + |
| 84 | + def test_add_integer_column(self): |
| 85 | + self._test_migrations( |
| 86 | + table_classes=[ |
| 87 | + create_table_class("MyTable"), |
| 88 | + create_table_class( |
| 89 | + "MyTable", class_members={"name": Integer()} |
| 90 | + ), |
| 91 | + ] |
| 92 | + ) |
| 93 | + |
| 94 | + def test_remove_integer_column(self): |
| 95 | + self._test_migrations( |
| 96 | + table_classes=[ |
| 97 | + create_table_class( |
| 98 | + "MyTable", class_members={"name": Integer()} |
| 99 | + ), |
| 100 | + create_table_class("MyTable"), |
| 101 | + ] |
| 102 | + ) |
0 commit comments