Ticket #735 (closed defect: fixed)

Opened 4 years ago

Last modified 3 months ago

Altering a column does not remove UNIQUE constraint

Reported by: Stephan Jaensch <sj@…> Owned by: andrew
Priority: minor Milestone: 1.0
Component: migrations Version: mercurial
Keywords: Cc:

Description

Using the Oracle backend, I have a migration modifying a column that has a UNIQUE constraint. The new column definition in the alter_column() call does not specify unique=True, but the constraint is not actually dropped.

Note that the other way around works just fine, namely altering a column and adding a UNIQUE constraint to it.

Change History

comment:1 Changed 4 years ago by andrew

  • Milestone set to 1.0

comment:2 Changed 4 years ago by Stephan Jaensch <sj@…>

These two changesets improve/fix constraint cache handling and make sure UNIQUE constraints are handled correctly during alter_column():

https://bitbucket.org/sjaensch/south/changeset/2a6f7bc2b8b9
https://bitbucket.org/sjaensch/south/changeset/2262cdf3a10f

This changeset implements a new testcase for this bug:

https://bitbucket.org/sjaensch/south/changeset/8c048cebe9b0

comment:3 Changed 4 years ago by sj@…

The new testcase did fail for PostgreSQL for two reasons. This changeset implements proper transaction handling:

https://bitbucket.org/sjaensch/south/changeset/20e16402bf3e

The second changeset implements UNIQUE constraint creation/deletion for alter_column() in the generic backend the same way the Oracle backend does it:

https://bitbucket.org/sjaensch/south/changeset/c5ff4ec6fe0c

Now PostgreSQL passes the test too. I did not test with MySQL or SQLite.

comment:4 Changed 4 years ago by andrew

  • Status changed from new to closed
  • Resolution set to fixed

All pulled.

Note: See TracTickets for help on using tickets.