Bug 9116 - migrations fail to apply on mysql
Summary: migrations fail to apply on mysql
Status: VERIFIED FIXED
Alias: None
Product: Toaster
Classification: Build System, Metadata & Runtime
Component: toaster (show other bugs)
Version: 2.1
Hardware: x86 Multiple
: Medium+ major
Target Milestone: 2.1 M3
Assignee: Michael Wood
QA Contact: Mihail Stanciu
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-02-15 11:52 UTC by Michael Wood
Modified: 2016-03-01 13:52 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Yes (doc changes required)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.