可以在此处找到解决方案:https://bugs.mysql.com/bug.php?id=102532。不确定 MySQL 开发人员是否打算重新打开此错误报告,因此您可能需要自己修复此问题。
具体来说,我终于在db_generic_migration_grt.py 中将问题追溯到这一行。我的堆栈跟踪如下:
Traceback:
File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\db_postgresql_migration_grt.py", line 313, in migrateCatalog
return instance.migrateCatalog(state, source_catalog)
File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\db_generic_migration_grt.py", line 182, in migrateCatalog
targetSchema = self.migrateSchema(state, sourceSchema, target_catalog)
File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\db_generic_migration_grt.py", line 218, in migrateSchema
self.migrateSchemaContents(state, targetSchema, sourceSchema)
File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\db_generic_migration_grt.py", line 234, in migrateSchemaContents
target_table = self.migrateTableToMySQL(state, source_table, targetSchema)
File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\db_sql92_migration_grt.py", line 36, in migrateTableToMySQL
targetTable = super(Sql92Migration, self).migrateTableToMySQL(state, sourceTable, targetSchema)
File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\db_generic_migration_grt.py", line 285, in migrateTableToMySQL
targetIndex = self.migrateTableIndexToMySQL(state, sourceIndex, targetTable)
File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\db_generic_migration_grt.py", line 424, in migrateTableIndexToMySQL
prefix_length_limit = min(referenced_index_col.length, MYSQL_MAX_INDEX_KEY_LENGTH_INNODB_UTF8) if referenced_index_col.length > 0 else MYSQL_MAX_INDEX_KEY_LENGTH_INNODB_UTF8
NameError: '>' not supported between instances of 'NoneType' and 'int'
00:43:23 [ERR][ Wizard]: Thread 'Migrate Selected Objects' failed: TypeError("'>' not supported between instances of 'NoneType' and 'int'"): error calling Python module function DbPostgresqlMigration.migrateCatalog
所有有问题的列都具有text 类型并且是主键。我相信这与 StackOverflow 讨论有关:MySQL error: key specification without a key length。
我通过在上面的 Python 文件中捕获错误并在这些情况下将 MYSQL_MAX_INDEX_KEY_LENGTH_INNODB_UTF8 分配为 prefix_length_limit 来解决了这个问题。不漂亮,但它很有效,所以我可以迁移数据。