Skip to content

Commit

Permalink
added a test for adding a column with an index using MigrationManager
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Feb 14, 2021
1 parent 55a5193 commit 9d5206a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/apps/migrations/auto/test_migration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@ def test_add_column(self):
response = self.run_sync("SELECT * FROM manager;")
self.assertEqual(response, [{"id": 1, "name": "Dave"}])

@postgres_only
def test_add_column_with_index(self):
"""
Test adding a column with an index to a MigrationManager.
"""
manager = MigrationManager()
manager.add_column(
table_class_name="Manager",
tablename="manager",
column_name="email",
column_class_name="Varchar",
params={
"length": 100,
"default": "",
"null": True,
"primary": False,
"key": False,
"unique": True,
"index": True,
},
)
index_name = Manager._get_index_name(["email"])

asyncio.run(manager.run())
self.assertTrue(index_name in Manager.indexes().run_sync())

# Reverse
asyncio.run(manager.run_backwards())
self.assertTrue(index_name not in Manager.indexes().run_sync())

@postgres_only
def test_add_foreign_key_self_column(self):
"""
Expand Down

0 comments on commit 9d5206a

Please sign in to comment.