[GH-ISSUE #19] Migrate Index Column size too large #8

Closed
opened 2026-02-27 10:25:16 +03:00 by kerem · 7 comments
Owner

Originally created by @msenebald on GitHub (Oct 26, 2015).
Original GitHub issue: https://github.com/modoboa/modoboa-postfix-autoreply/issues/19

Hi,

just updated to Postfix autoreply 1.1.1 and run the migrate.
But I get the following error.

python manage.py migrate modoboa_postfix_autoreply
Operations to perform:
  Apply all migrations: modoboa_postfix_autoreply
Running migrations:
  Applying modoboa_postfix_autoreply.0002_auto_20150728_1236...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 161, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/migrations/executor.py", line 68, in migrate
    self.apply_migration(migration, fake=fake)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/migrations/executor.py", line 102, in apply_migration
    migration.apply(project_state, schema_editor)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/migrations/migration.py", line 108, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 139, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/schema.py", line 470, in alter_field
    self._alter_field(model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/schema.py", line 647, in _alter_field
    self.execute(self._create_index_sql(model, [new_field], suffix="_uniq"))
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/schema.py", line 111, in execute
    cursor.execute(sql, params)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 129, in execute
    return self.cursor.execute(query, args)
  File "/opt/modoboa/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/opt/modoboa/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.OperationalError: (1709, 'Index column size too large. The maximum column size is 767 bytes.')

I tried to find the migration file and check what it is trying to do but failed to do so.
Database is a InnoDB

Autoreply Schemas look like:

CREATE TABLE `postfix_autoreply_transport` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `domain` varchar(300) NOT NULL,
  `method` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

CREATE TABLE `postfix_autoreply_armessage` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subject` varchar(255) NOT NULL,
  `content` longtext NOT NULL,
  `enabled` tinyint(1) NOT NULL,
  `fromdate` datetime NOT NULL,
  `untildate` datetime DEFAULT NULL,
  `mbox_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `postfix_autoreply_armessage_5419c569` (`mbox_id`),
  CONSTRAINT `postfix_autoreply_a_mbox_id_739f665fbc7b21df_fk_admin_mailbox_id` FOREIGN KEY (`mbox_id`) REFERENCES `admin_mailbox` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

CREATE TABLE `postfix_autoreply_arhistoric` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `last_sent` datetime NOT NULL,
  `sender` varchar(254) NOT NULL,
  `armessage_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `postfix_autoreply_arhistoric_armessage_id_1d0bc60837459629_uniq` (`armessage_id`,`sender`),
  KEY `postfix_autoreply_arhistoric_edbe1cb9` (`armessage_id`),
  CONSTRAINT `armessage_id_2d1162f27ac3471b_fk_postfix_autoreply_armessage_id` FOREIGN KEY (`armessage_id`) REFERENCES `postfix_autoreply_armessage` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `postfix_autoreply_alias` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `full_address` varchar(255) NOT NULL,
  `autoreply_address` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

Thanks for any help.

BR Martin

Originally created by @msenebald on GitHub (Oct 26, 2015). Original GitHub issue: https://github.com/modoboa/modoboa-postfix-autoreply/issues/19 Hi, just updated to Postfix autoreply 1.1.1 and run the migrate. But I get the following error. ``` python manage.py migrate modoboa_postfix_autoreply Operations to perform: Apply all migrations: modoboa_postfix_autoreply Running migrations: Applying modoboa_postfix_autoreply.0002_auto_20150728_1236...Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__) File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute output = self.handle(*args, **options) File "/opt/modoboa/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 161, in handle executor.migrate(targets, plan, fake=options.get("fake", False)) File "/opt/modoboa/lib/python2.7/site-packages/django/db/migrations/executor.py", line 68, in migrate self.apply_migration(migration, fake=fake) File "/opt/modoboa/lib/python2.7/site-packages/django/db/migrations/executor.py", line 102, in apply_migration migration.apply(project_state, schema_editor) File "/opt/modoboa/lib/python2.7/site-packages/django/db/migrations/migration.py", line 108, in apply operation.database_forwards(self.app_label, schema_editor, project_state, new_state) File "/opt/modoboa/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 139, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/schema.py", line 470, in alter_field self._alter_field(model, old_field, new_field, old_type, new_type, old_db_params, new_db_params, strict) File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/schema.py", line 647, in _alter_field self.execute(self._create_index_sql(model, [new_field], suffix="_uniq")) File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/schema.py", line 111, in execute cursor.execute(sql, params) File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) File "/opt/modoboa/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) File "/opt/modoboa/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 129, in execute return self.cursor.execute(query, args) File "/opt/modoboa/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute self.errorhandler(self, exc, value) File "/opt/modoboa/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue django.db.utils.OperationalError: (1709, 'Index column size too large. The maximum column size is 767 bytes.') ``` I tried to find the migration file and check what it is trying to do but failed to do so. Database is a InnoDB Autoreply Schemas look like: ``` SQL CREATE TABLE `postfix_autoreply_transport` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain` varchar(300) NOT NULL, `method` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8; CREATE TABLE `postfix_autoreply_armessage` ( `id` int(11) NOT NULL AUTO_INCREMENT, `subject` varchar(255) NOT NULL, `content` longtext NOT NULL, `enabled` tinyint(1) NOT NULL, `fromdate` datetime NOT NULL, `untildate` datetime DEFAULT NULL, `mbox_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `postfix_autoreply_armessage_5419c569` (`mbox_id`), CONSTRAINT `postfix_autoreply_a_mbox_id_739f665fbc7b21df_fk_admin_mailbox_id` FOREIGN KEY (`mbox_id`) REFERENCES `admin_mailbox` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; CREATE TABLE `postfix_autoreply_arhistoric` ( `id` int(11) NOT NULL AUTO_INCREMENT, `last_sent` datetime NOT NULL, `sender` varchar(254) NOT NULL, `armessage_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `postfix_autoreply_arhistoric_armessage_id_1d0bc60837459629_uniq` (`armessage_id`,`sender`), KEY `postfix_autoreply_arhistoric_edbe1cb9` (`armessage_id`), CONSTRAINT `armessage_id_2d1162f27ac3471b_fk_postfix_autoreply_armessage_id` FOREIGN KEY (`armessage_id`) REFERENCES `postfix_autoreply_armessage` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `postfix_autoreply_alias` ( `id` int(11) NOT NULL AUTO_INCREMENT, `full_address` varchar(255) NOT NULL, `autoreply_address` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; ``` Thanks for any help. BR Martin
kerem 2026-02-27 10:25:16 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tonioo commented on GitHub (Nov 12, 2015):

Hi, unfortunately it seems to be a MySQL+InnoDB limitation (according to http://south.aeracode.org/ticket/39 and http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes.

I suggest you try this workaround: http://mechanics.flite.com/blog/2014/07/29/using-innodb-large-prefix-to-avoid-error-1071/.

Please tell me if it works.

<!-- gh-comment-id:156073145 --> @tonioo commented on GitHub (Nov 12, 2015): Hi, unfortunately it seems to be a MySQL+InnoDB limitation (according to http://south.aeracode.org/ticket/39 and http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes. I suggest you try this workaround: http://mechanics.flite.com/blog/2014/07/29/using-innodb-large-prefix-to-avoid-error-1071/. Please tell me if it works.
Author
Owner

@tonioo commented on GitHub (Nov 19, 2015):

@msenebald ping

<!-- gh-comment-id:158018532 --> @tonioo commented on GitHub (Nov 19, 2015): @msenebald ping
Author
Owner

@msenebald commented on GitHub (Jan 1, 2016):

Hi,
sorry for the delay. I tried the workaround, but without success.
Since i am not so familiar with django, i a not sure how to get the sql code that is generated by the migration.
What I did, I removed the index option in the migration "db_index=True" from:
migrations/0002_auto_20150728_1236.py

 field=models.CharField(max_length=300, db_index=True),

it happily upgrades the rest. But now without index.
I use mariadb 5.5.44 from official centos 7 repo.

<!-- gh-comment-id:168320379 --> @msenebald commented on GitHub (Jan 1, 2016): Hi, sorry for the delay. I tried the workaround, but without success. Since i am not so familiar with django, i a not sure how to get the sql code that is generated by the migration. What I did, I removed the index option in the migration "db_index=True" from: migrations/0002_auto_20150728_1236.py ``` python field=models.CharField(max_length=300, db_index=True), ``` it happily upgrades the rest. But now without index. I use mariadb 5.5.44 from official centos 7 repo.
Author
Owner

@tonioo commented on GitHub (Jan 4, 2016):

Have you tried to recreate indexes after the migration ?

<!-- gh-comment-id:168674856 --> @tonioo commented on GitHub (Jan 4, 2016): Have you tried to recreate indexes after the migration ?
Author
Owner

@tenninjas commented on GitHub (Feb 2, 2016):

This can be solved by changing max_length to 253, which would seem sensible since domain names cannot acceptably exceed 253 characters in any case.

<!-- gh-comment-id:178354912 --> @tenninjas commented on GitHub (Feb 2, 2016): This can be solved by changing max_length to 253, which would seem sensible since domain names cannot acceptably exceed 253 characters in any case.
Author
Owner

@armouredking commented on GitHub (Feb 24, 2016):

The workaround you've noted ( large prefix ) only works with an additional two steps:

  1. The server is setup to use Barracuda ( default is Antelope because backwards compat. )
  2. The table row is setup to use the right ROW_FORMAT.

The second issue is generally what gets people. It's easy enough to switch over to Barracuda, but the ROW_FORMAT option needs to be specified depending on your server setup. The default ROW_FORMAT is usually set to COMPACT ( even my latest edition install of MariaDB 10.1 was set to COMPACT ); you need to append the ROW_FORMAT=DYNAMIC; or whatever you want to use to the actual CREATE line, like so:

CREATE TABLE `postfix_autoreply_transport` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `domain` varchar(300) NOT NULL,
  `method` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

Or change your ROW_FORMAT=DEFAULT option to use DYNAMIC instead of REDUNDANT or COMPACT if you'd rather not deal. COMPRESSED cannot be set globally. ( Edit to note: This is only present in really really new versions. You probably don't have it - I don't. Explicitly setting the option is the only way atm ).

For more information about ROW_FORMAT see the manual.

<!-- gh-comment-id:188374416 --> @armouredking commented on GitHub (Feb 24, 2016): The workaround you've noted ( large prefix ) only works with an additional two steps: 1. The server is setup to use _[Barracuda](https://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_barracuda)_ ( default is _[Antelope](https://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_antelope)_ because backwards compat. ) 2. The table row is setup to use the right `ROW_FORMAT`. The second issue is generally what gets people. It's easy enough to switch over to _Barracuda_, but the `ROW_FORMAT` option needs to be specified depending on your server setup. The default `ROW_FORMAT` is usually set to `COMPACT` ( even my latest edition install of MariaDB 10.1 was set to `COMPACT` ); you need to append the `ROW_FORMAT=DYNAMIC;` or whatever you want to use to the actual `CREATE` line, like so: ``` CREATE TABLE `postfix_autoreply_transport` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain` varchar(300) NOT NULL, `method` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; ``` Or change your `ROW_FORMAT=DEFAULT` option to use `DYNAMIC` instead of `REDUNDANT` or `COMPACT` if you'd rather not deal. `COMPRESSED` cannot be set globally. ( Edit to note: This is only present in really really new versions. You probably don't have it - I don't. Explicitly setting the option is the only way atm ). For more information about `ROW_FORMAT` see [the manual](https://dev.mysql.com/doc/refman/5.6/en/innodb-row-format.html).
Author
Owner

@msenebald commented on GitHub (Apr 1, 2016):

Perfect. Thanks for your help @tonioo !

<!-- gh-comment-id:204528311 --> @msenebald commented on GitHub (Apr 1, 2016): Perfect. Thanks for your help @tonioo !
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-postfix-autoreply-modoboa#8
No description provided.