bitbake: toaster: Make 0021 migration compatible with MySQL

Two issues prevent this migration from working correctly
with a MySQL back-end:

1. MySQL won't allow a default value to be set for an
AutoField, which is what the migration tries to do
for project_id ("ValueError: The database backend does not accept
0 as a value for AutoField.")

2. When migrations are applied to a MySQL back-end, Django
(via South) attempts a dry run of the migration first: it
applies the forward migration then rolls it back. However, this
migration raises an exception on roll back, which causes the
whole series of migrations to fail.

This commit fixes both issues.

[YOCTO #7932]

(Bitbake rev: 12f6278d56d7dec57308adc17411802f15d395d7)

Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Elliot Smith authored and Richard Purdie committed 2015-09-03 16:52:48 +01:00
1 parent 24d6d3fda8
commit 5b26bbdfe1
1 file changed
+3 -1
@@ -7,10 +7,12 @@ from django.db import models
class Migration(SchemaMigration):
no_dry_run = True
def forwards(self, orm):
# Changing field 'Build.project'
db.alter_column(u'orm_build', 'project_id', self.gf('django.db.models.fields.related.ForeignKey')(default=0, to=orm['orm.Project']))
db.alter_column(u'orm_build', 'project_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['orm.Project']))
# Changing field 'Project.bitbake_version'
db.alter_column(u'orm_project', 'bitbake_version_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['orm.BitbakeVersion'], null=True))