File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
tests/apps/migrations/auto Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 44from asyncpg .exceptions import UniqueViolationError
55from piccolo .apps .migrations .auto import MigrationManager
66from piccolo .apps .migrations .commands .base import BaseMigrationManager
7- from piccolo .columns import Varchar
7+ from piccolo .columns import Varchar , Text
88from piccolo .columns .base import OnDelete , OnUpdate
99
1010from tests .example_app .tables import Manager
@@ -467,6 +467,30 @@ def test_alter_column_add_index(self):
467467 not in Manager .indexes ().run_sync ()
468468 )
469469
470+ @postgres_only
471+ def test_alter_column_set_type (self ):
472+ """
473+ Test altering a column to change it's type with MigrationManager.
474+ """
475+ manager = MigrationManager ()
476+
477+ manager .alter_column (
478+ table_class_name = "Manager" ,
479+ tablename = "manager" ,
480+ column_name = "name" ,
481+ params = {},
482+ old_params = {},
483+ column_class = Text ,
484+ old_column_class = Varchar ,
485+ )
486+
487+ asyncio .run (manager .run ())
488+
489+ column_type_str = self .get_postgres_column_type_str (
490+ tablename = "manager" , column_name = "name"
491+ )
492+ self .assertEqual (column_type_str , "TEXT" )
493+
470494 @postgres_only
471495 @patch .object (BaseMigrationManager , "get_migration_managers" )
472496 def test_drop_table (self , get_migration_managers : MagicMock ):
You can’t perform that action at this time.
0 commit comments