Changes between Initial Version and Version 1 of Ticket #24410


Ignore:
Timestamp:
Feb 24, 2015, 3:52:44 PM (9 years ago)
Author:
László Károlyi
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24410

    • Property Component UncategorizedDatabase layer (models, ORM)
    • Property Type UncategorizedBug
  • Ticket #24410 – Description

    initial v1  
    11Hey,
    22
    3 Using Django 1.7's migrations with MySQL, when I need to create a custom index on a column (`Specified key was too long; max key length is 767 bytes`, thus the column needs a prefix length), it's not recognized, not deleted when migrating backwards and the erroneous index creation SQL is recreated in the next migration, causing the migration to fail, or creating another index which emits a MySQL warning (`_mysql_exceptions.Warning: Duplicate index 'cdn_image_cdn_path_2654d3de68657258_uniq' defined on the table 'xxx.cdn_image'. This is deprecated and will be disallowed in a future release.`), thus causing the migration to fail.
     3Using Django 1.7's migrations with MySQL, when I need to create a custom index on a column with a big length (`_mysql_exceptions.Warning: Specified key was too long; max key length is 767 bytes`, thus the column needs a prefix length), it's not recognized, AND not deleted when migrating backwards. The erroneous index creation SQL is recreated in the next migration, causing the migration to fail, and creating another index which emits a MySQL warning (`_mysql_exceptions.Warning: Duplicate index 'cdn_image_cdn_path_2654d3de68657258_uniq' defined on the table 'xxx.cdn_image'. This is deprecated and will be disallowed in a future release.`), thus causing the migration to fail.
    44
    55Here's the model:
     
    2323        return self.cdn_path
    2424}}}
     25
     26Try creating migrations with changing the db_index property on the `orig_src` field, and you'll see it happen.
     27
     28What I did to create my custom index is to add a special migration to my migration file:
     29
     30{{{
     31        migrations.RunSQL(
     32            'CREATE INDEX `cdn_image_orig_src_uniq` ON `cdn_image` (`orig_src`(255))',
     33            reverse_sql='DROP INDEX `cdn_image_orig_src_uniq` ON `cdn_image`'),
     34}}}
     35
     36Nothing helps here. Even if the index is created manually, the next migration will try to create an erroneous statement for MySQL, and the migration fail.
     37
     38The other interesting phenomenon is, when migrating backwards, other indexes which are created successfully in former steps (like the one on `cdn_path`), are not removed. On the next forward migration, the above mentioned warning occurs, and the migration fails.
     39
     40This blocks me from proceeding with my development. Please fix this bug ASAP.
Back to Top