Revision bff77975 peers/migrations/0002_auto__chg_field_peer_peer_id.py
b/peers/migrations/0002_auto__chg_field_peer_peer_id.py | ||
---|---|---|
5 | 5 |
from django.db import models |
6 | 6 |
|
7 | 7 |
|
8 |
# Probably due to a MySQL bug, the AutoField is not created properly and raises a |
|
9 |
# "Warning 1364: Field 'peer_id' doesn't have a default value" exception on inserts via Django admin. |
|
10 |
# This does not make sense... No exception comes up once insterts are done via MySQL cli or phpmyadmin |
|
11 |
# What seems to cause this issue is a South generated sql query: |
|
12 |
# ALTER TABLE `peer` ALTER COLUMN `peer_id` DROP DEFAULT; |
|
13 |
# will have to override _alter_set_defaults |
|
14 |
def new_alter_columns_set_default(field, name, params, sqls): |
|
15 |
return |
|
16 |
|
|
17 |
db._alter_set_defaults = new_alter_columns_set_default |
|
18 |
|
|
8 | 19 |
class Migration(SchemaMigration): |
9 | 20 |
|
10 | 21 |
def forwards(self, orm): |
11 |
|
|
22 |
|
|
12 | 23 |
# Changing field 'Peer.peer_id' |
13 | 24 |
db.alter_column(u'peer', 'peer_id', self.gf('django.db.models.fields.AutoField')(primary_key=True)) |
14 | 25 |
|
Also available in: Unified diff