Add support for Alembic migrations to detect column size changes

Bug #1433870 reported by Michael Davies
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Opinion
Wishlist
Unassigned

Bug Description

As part of implementing https://review.openstack.org/#/c/165666 I discovered that the default configuration that Ironic has for Alembic does not detect changes to column sizes when generating migrations.

The Lazy Web told me about a fix for this over at http://stackoverflow.com/questions/17174636/can-alembic-autogenerate-column-alterations

I think we should probably do something like this for the default configuration for Ironic. I've used this fix locally to generate https://review.openstack.org/#/c/165666/3/ironic/db/sqlalchemy/alembic/versions/2fb93ffd2af1_increase_node_name_length.py but unfortunately it also suggests a number of migration changes that were unexpected.

    op.alter_column('conductors', 'online',
               existing_type=mysql.TINYINT(display_width=1),
               type_=sa.Boolean(),
               existing_nullable=True)
    op.alter_column('nodes', 'console_enabled',
               existing_type=mysql.TINYINT(display_width=1),
               type_=sa.Boolean(),
               existing_nullable=True)
    op.alter_column('nodes', 'maintenance',
               existing_type=mysql.TINYINT(display_width=1),
               type_=sa.Boolean(),
               existing_nullable=True)

We need to investigate whether these additional changes are legit, and we need to decide whether we want this enabled for all auto-generate alembic migration changes.

Tags: db
Michael Davies (mrda)
description: updated
Revision history for this message
David Shrewsbury (dshrews) wrote :

I am a little bit wary of enabling this because of this statement in the documentation, found at:

http://alembic.readthedocs.org/en/latest/api.html#alembic.environment.EnvironmentContext.configure.params.compare_type

"Set to True to turn on default type comparison, which has varied accuracy depending on backend."

The whole "varied accuracy" thing scares me.

As for the changes to the other columns (online, console_enabled, maintenance), they are already defined as BOOLEAN in the models.py file, but that is an alias in MySQL for TINYINT. So these may be no-op changes, but strange that alembic doesn't recognize that.

Revision history for this message
Dmitry Tantsur (divius) wrote :

Hmm, yeah, worth investigation, but we probably should not rush enabling it as it is...

Changed in ironic:
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
Viktor Serhieiev (vsergeyev) wrote :

Well, Alembic autogeneration tool "is not intended to be perfect" - please see the list of changes, with can and can't be detected at [1]. Also, you can find some custom type comparators in oslo.db.

[1] http://alembic.readthedocs.org/en/latest/autogenerate.html#what-does-autogenerate-detect-and-what-does-it-not-detect

tags: added: db
Revision history for this message
Michael Turek (mjturek) wrote :

This wishlist bug has been open more than a year without any activity. I'm going to move it to "Opinion / Wishlist", which is an easily-obtainable queue of older requests that have come on. This bug can be reopened (set back to "New") if someone decides to work on this.

Changed in ironic:
status: Confirmed → Opinion
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.