From baa4918d89af14a3646a65332fa40ca2e68c0555 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Tue, 6 Jan 2015 14:55:31 -0500 Subject: [PATCH 1/2] Explicitly declare length of large MySQL indices. Most MySQL installs silently truncate indices at a specific number of bytes. This value is 767 bytes unless either the innodb_large_prefix option is turned on or the innodb_page_size has been changed. This change explicitly limits the size of large indices to 767 characters due to the latin1 charset being 1 byte per char. --- .../228d1af6af1c_mysql_max_index_lengths.py | 22 +++++++++++++++++++ .../5a07499ce53f_set_up_initial_database.py | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 data/migrations/versions/228d1af6af1c_mysql_max_index_lengths.py diff --git a/data/migrations/versions/228d1af6af1c_mysql_max_index_lengths.py b/data/migrations/versions/228d1af6af1c_mysql_max_index_lengths.py new file mode 100644 index 000000000..0b70acbb3 --- /dev/null +++ b/data/migrations/versions/228d1af6af1c_mysql_max_index_lengths.py @@ -0,0 +1,22 @@ +"""mysql max index lengths + +Revision ID: 228d1af6af1c +Revises: 5b84373e5db +Create Date: 2015-01-06 14:35:24.651424 + +""" + +# revision identifiers, used by Alembic. +revision = '228d1af6af1c' +down_revision = '5b84373e5db' + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +def upgrade(tables): + op.drop_index('queueitem_queue_name', table_name='queueitem') + op.create_index('queueitem_queue_name', 'queueitem', ['queue_name'], unique=False, mysql_length=767) + +def downgrade(tables): + pass diff --git a/data/migrations/versions/5a07499ce53f_set_up_initial_database.py b/data/migrations/versions/5a07499ce53f_set_up_initial_database.py index 0e786de14..c1d082066 100644 --- a/data/migrations/versions/5a07499ce53f_set_up_initial_database.py +++ b/data/migrations/versions/5a07499ce53f_set_up_initial_database.py @@ -53,7 +53,7 @@ def upgrade(tables): op.create_index('queueitem_available', 'queueitem', ['available'], unique=False) op.create_index('queueitem_available_after', 'queueitem', ['available_after'], unique=False) op.create_index('queueitem_processing_expires', 'queueitem', ['processing_expires'], unique=False) - op.create_index('queueitem_queue_name', 'queueitem', ['queue_name'], unique=False) + op.create_index('queueitem_queue_name', 'queueitem', ['queue_name'], unique=False, mysql_length=767) op.create_table('role', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=255), nullable=False), @@ -376,7 +376,7 @@ def upgrade(tables): sa.ForeignKeyConstraint(['storage_id'], ['imagestorage.id'], ), sa.PrimaryKeyConstraint('id') ) - op.create_index('image_ancestors', 'image', ['ancestors'], unique=False) + op.create_index('image_ancestors', 'image', ['ancestors'], unique=False, mysql_length=767) op.create_index('image_repository_id', 'image', ['repository_id'], unique=False) op.create_index('image_repository_id_docker_image_id', 'image', ['repository_id', 'docker_image_id'], unique=True) op.create_index('image_storage_id', 'image', ['storage_id'], unique=False) From b18986c72bcec60f8e032222ee6c32ae9326510a Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Tue, 6 Jan 2015 15:11:37 -0500 Subject: [PATCH 2/2] Continuation of baa4918d89. --- .../versions/228d1af6af1c_mysql_max_index_lengths.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/migrations/versions/228d1af6af1c_mysql_max_index_lengths.py b/data/migrations/versions/228d1af6af1c_mysql_max_index_lengths.py index 0b70acbb3..2f6ff722b 100644 --- a/data/migrations/versions/228d1af6af1c_mysql_max_index_lengths.py +++ b/data/migrations/versions/228d1af6af1c_mysql_max_index_lengths.py @@ -18,5 +18,8 @@ def upgrade(tables): op.drop_index('queueitem_queue_name', table_name='queueitem') op.create_index('queueitem_queue_name', 'queueitem', ['queue_name'], unique=False, mysql_length=767) + op.drop_index('image_ancestors', table_name='image') + op.create_index('image_ancestors', 'image', ['ancestors'], unique=False, mysql_length=767) + def downgrade(tables): pass