Skip to content

Commit

Permalink
Fixed #1371: Keep the unique flag in DropIndexOp
Browse files Browse the repository at this point in the history
  • Loading branch information
Iuri de Silvio committed Dec 1, 2023
1 parent e8f6a85 commit 5d6616c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions alembic/operations/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ def from_index(cls, index: Index) -> DropIndexOp:
table_name=index.table.name,
schema=index.table.schema,
_reverse=CreateIndexOp.from_index(index),
unique=index.unique,
**index.kwargs,
)

Expand Down
6 changes: 6 additions & 0 deletions tests/test_autogen_diffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,7 @@ def setUp(self):
Column("x", Integer()),
)
self.ix = Index("ix1", t.c.id)
self.ix_unique = Index("ix2", t.c.id, unique=True)
fk = ForeignKeyConstraint(["t_id"], ["t.id"])
q = Table("q", m, Column("t_id", Integer()), fk)
self.table = t
Expand Down Expand Up @@ -1905,6 +1906,11 @@ def test_create_index(self):
eq_(op.to_index(), schemacompare.CompareIndex(self.ix))
eq_(op.reverse().to_index(), schemacompare.CompareIndex(self.ix))

def test_create_unique_index(self):
op = ops.CreateIndexOp.from_index(self.ix_unique)
eq_(op.to_index(), schemacompare.CompareIndex(self.ix_unique))
eq_(op.reverse().to_index(), schemacompare.CompareIndex(self.ix_unique))


class MultipleMetaDataTest(AutogenFixtureTest, TestBase):
def test_multiple(self):
Expand Down

0 comments on commit 5d6616c

Please sign in to comment.