Bug 9116

Summary: migrations fail to apply on mysql
Product: [Build System, Metadata & Runtime] Toaster Reporter: Michael Wood <michael.g.wood>
Component: toasterAssignee: Michael Wood <michael.g.wood>
Status: VERIFIED FIXED QA Contact: Mihail Stanciu <stanciux.mihail>
Severity: major    
Priority: Medium+ CC: belen.barros.pena, brian.avery, jessica.zhang, stanciux.mihail
Version: 2.1   
Target Milestone: 2.1 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Michael Wood 2016-02-15 11:52:31 UTC
Currently the migrations fail to apply on mysql

django.db.utils.OperationalError: (1829, "Cannot drop column 'id': needed in a foreign key constraint 'D1a8c915f90ee0694e71f27b384a7341' of table 'toaster.orm_customimagerecipe_packages'")

This is because of mysql doesn't support being able to drop a primary key which is currently 'in use'. orm.0002_auto_20151210_1209

We may need to detect if we're using mysql and do a slightly different migration.
Comment 1 Michael Wood 2016-02-16 10:59:06 UTC
After investigation we have no choice other than to reset migrations

I've tried adding an intermediate migration which drops the CustomImageRecipe table and recreates it but this hits a Django bug https://code.djangoproject.com/ticket/24225 I've also tried renaming it and various combinations of removing all the fields which hold the foreign key relationship and then re-creating them with the corrected relationships. We also have a slightly broken migration tree with two migrations 0002 that depend on the initial migration.
Comment 2 brian avery 2016-02-17 03:55:34 UTC
If I have a toaster.sqlite from jethro, these migrations break on the existing jethro database.  If so, we will need to spell out in the docs that in order to take advantage of the new image customization feature users will need to start with a fresh db.
Comment 3 Michael Wood 2016-02-29 14:59:27 UTC
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=8469e5802590551dbf88a26539b9cfe5710c074d

 (Bitbake rev: 19bd63fc3a28dcbd0f531a5b06a037da34568bac)
Comment 4 Mihail Stanciu 2016-03-01 13:52:03 UTC
Verified while setting up MySQL instance for GDC.