Ticket #431 (assigned defect)

Opened 4 years ago

Last modified 3 years ago

db.alter_column() cannot change default value in MySQL

Reported by: fcamel@… Owned by: andrew
Priority: major Milestone: 1.0
Component: databaseapi Version: 0.7
Keywords: Cc:


Here is my server information:

  • mysql 5.0.51a
  • ubuntu 8.04

Using db.alter_column() to change the default value works in sqlite3 but fails in MySQL.

class Name(models.Model):
    n = models.IntegerField(default=3)

Part of the migration script:

class Migration(SchemaMigration):

    def forwards(self, orm):
        db.alter_column('my_app_name', 'n', models.IntegerField(default=40))

    def backwards(self, orm):
        db.alter_column('my_app_name', 'n', models.IntegerField(default=3))

After running "migrate" (forward or backward), the default value is changed to None.


Change History

comment:1 Changed 4 years ago by andrew

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

comment:2 Changed 4 years ago by andrew

  • Milestone changed from 0.7.2 to 0.7.3

comment:3 Changed 4 years ago by andrew

  • Milestone changed from 0.7.3 to 1.0

Add a comment

Modify Ticket

as assigned

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

Note: See TracTickets for help on using tickets.