WordPress / sqlite-database-integration

Feature Plugin to add SQLite support to WordPress. Under Development.
GNU General Public License v2.0
223 stars 37 forks source link

Fix length of index names for a create table statement #133

Closed jeroenpf closed 2 months ago

jeroenpf commented 2 months ago

Fixes: #124

This PR introduces some changes to how we determine the name of an index. SQLite requires that each index is uniquely named across the database (not just the table). This causes issues when multiple tables have the same key names when importing from MySQL. To avoid these issues, the index name is prefixed with the table name when it is created. This however results in the indexes having names that are too long for MySQL so when we run show create table the create statements have these prefixed keys that are too long.

To solve this, we keep adding the table name as a prefix but we remove it when we generate the create statement. Furthermore, we ensure that the table name itself has no double underscores in it so we can be sure that we can split on __ safely. The result is that each create table statement will have the original index name and prevents it from being too long.

jeroenpf commented 2 months ago

@bgrgicak Could you have a look at this one?

bgrgicak commented 2 months ago

Thank you @jeroenpf for contributing these fixes!