[Toaster] [review-request][PATCH] toaster: make 0021 migration compatible with MySQL

Damian, Alexandru alexandru.damian at intel.com
Fri Aug 14 03:51:51 PDT 2015


Hello,

One of intended effects of this migration is to make sure that we have a
Project with id "0" and release None after this migration is run.

After this patch is merged, there is no guarantee that this entry in the
database will exist, unless I'm missing something.

Can you please add code to the migration to automatically add the Project
id 0 entry if it does not exist ?

Also, can you please check what is going on with the white space changes ?

Cheers,
Alex

On Fri, Aug 14, 2015 at 11:39 AM, Elliot Smith <elliot.smith at intel.com>
wrote:

> 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 patch fixes both issues.
>
> Fixes https://bugzilla.yoctoproject.org/show_bug.cgi?id=7932
>
> Signed-off-by: Elliot Smith <elliot.smith at intel.com>
> ---
>  ...d_build_project__chg_field_project_bitbake_version__chg_.py | 10
> ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git
> a/bitbake/lib/toaster/orm/migrations/0021_auto__chg_field_build_project__chg_field_project_bitbake_version__chg_.py
> b/bitbake/lib/toaster/orm/migrations/0021_auto__chg_field_build_project__chg_field_project_bitbake_version__chg_.py
> index 924a5c4..c4e459b 100644
> ---
> a/bitbake/lib/toaster/orm/migrations/0021_auto__chg_field_build_project__chg_field_project_bitbake_version__chg_.py
> +++
> b/bitbake/lib/toaster/orm/migrations/0021_auto__chg_field_build_project__chg_field_project_bitbake_version__chg_.py
> @@ -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))
> @@ -31,14 +33,14 @@ class Migration(SchemaMigration):
>
>          # User chose to not deal with backwards NULL issues for
> 'Project.bitbake_version'
>          raise RuntimeError("Cannot reverse this migration.
> 'Project.bitbake_version' and its values cannot be restored.")
> -
> +
>          # The following code is provided here to aid in writing a correct
> migration
>          # 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']))
>
>          # User chose to not deal with backwards NULL issues for
> 'Project.release'
>          raise RuntimeError("Cannot reverse this migration.
> 'Project.release' and its values cannot be restored.")
> -
> +
>          # The following code is provided here to aid in writing a correct
> migration
>          # Changing field 'Project.release'
>          db.alter_column(u'orm_project', 'release_id', self.gf
> ('django.db.models.fields.related.ForeignKey')(to=orm['orm.Release']))
> @@ -366,4 +368,4 @@ class Migration(SchemaMigration):
>          }
>      }
>
> -    complete_apps = ['orm']
> \ No newline at end of file
> +    complete_apps = ['orm']
> --
> Elliot Smith
> Software Engineer
> Intel OTC
>
> ---------------------------------------------------------------------
> Intel Corporation (UK) Limited
> Registered No. 1134945 (England)
> Registered Office: Pipers Way, Swindon SN3 1RJ
> VAT No: 860 2173 47
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> --
> _______________________________________________
> toaster mailing list
> toaster at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/toaster
>



-- 
Alex Damian
Yocto Project
SSG / OTC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/toaster/attachments/20150814/d5e326fb/attachment.html>


More information about the toaster mailing list