Modify

Ticket #83 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

alter_table does not take care of constraints

Reported by: ck@… Owned by: andrew
Priority: major Milestone: 0.5
Component: commands Version: 0.4
Keywords: Cc:

Description

When trying to convert a PositiveSmallIntegerField? to a SmallIntegerField? alter_table does not drop the constraints that take care of the values being positive.

So when doing something like this:

def forwards(self):
  db.alter_column('forum_category', 'order', models.SmallIntegerField(default=0))
    
def backwards(self):
  db.alter_column('forum_category', 'order', models.PositiveSmallIntegerField(default=0))

The migration will run without problems but effectively does nothing.

Attachments

Change History

comment:1 Changed 5 years ago by ck@…

Oh sorry, forgot to select the right component.

comment:2 Changed 5 years ago by andrew

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

Indeed, that's a good find. I'll try to fix it in the next week or so.

comment:3 Changed 5 years ago by andrew

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

OK, this is a tough one. [224] contains a fix for the problem here, but there's still the problem of adding the constraint back in when the column is converted back; things like this may well need a patch to Django core, and in the interim a dict of special cases, so columns can give their constraints properly rather than assuming the types are going into a CREATE TABLE.

Anyway, only Postgres supports this constraint at the moment anyway, so Django must be checking for it Python-side anyway, so closing this one as fixed.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.