Ticket #243 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

Renaming a ForeignKey in MySQL/Innodb

Reported by: elsdoerfer@… Owned by: andrew
Priority: major Milestone: 0.7.1
Component: databaseapi Version: 0.6
Keywords: Cc:


db.rename_column('app_model', 'valuation', 'estimate',)

fails with:

ValueError?: No column 'valuation' in 'app_model'.

If I specify the columns using an _id suffix:

db.rename_column('app_model', 'valuation_id', 'estimate_id',)

The rename itself works, but the foreignkeys make trouble:

OperationalError?: (1025, "Error on rename of ...

Change History

comment:1 Changed 6 years ago by andrew

  • Status changed from new to assigned
  • Milestone set to 0.7

comment:2 Changed 6 years ago by andrew

  • Milestone changed from 0.7 to 0.7.1

The first error has been fixed in 0.7, as it was a generation issue.

The second error is more an issue with MySQL/InnoDB; it won't automatically move the FK constraint along with the column rename (Postgres does, in this case). We'll have to manually fix up the FKs for MySQL, which is quite a bit of work, so bumping to 0.7.1.

comment:3 Changed 6 years ago by andrew

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

Closing this ticket as "fixed" for the first half, as #466 is a bug about just part 2.

Note: See TracTickets for help on using tickets.