Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make unique index compatible with database without long key support #18723

Merged
merged 2 commits into from Feb 2, 2022

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Feb 2, 2022

Description:

Not sure if that is the most elegant solution. But can't think of something better right now.

fixes #18721

Review

@sgiehl sgiehl added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Feb 2, 2022
@sgiehl sgiehl added this to the 4.7.1 milestone Feb 2, 2022
@MatomoForumNotifications

This pull request has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/4-7-0-b2-update-fails-with-mysql-5-5/44603/10

@@ -362,14 +362,14 @@ public function getTablesCreateSql()
'changes' => "CREATE TABLE `{$prefixTables}changes` (
`idchange` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`created_time` DATETIME NOT NULL,
`plugin_name` VARCHAR(255) NOT NULL,
`plugin_name` VARCHAR(40) NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgiehl seems in other tables we have a 60 character limit in the DB like plugin_setting, site_setting. Does it make sense to apple this here as well? We could create a follow up issue for Matomo 5 (to not break anything) to adjust isValidPluginName to limit to max 60 characters. Checked our longest plugin name so far is around 30 characters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the developer docs say the max length should be 40. But we can also use 60. No preference there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK we can leave it at 40. I will create a follow up issue then to change the other columns to 40 as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe let's use 60 @sgiehl for consistency with the other tables. I'm sure it be fine to use 40, but better have consistency for now. I created follow up issue for Matomo 5 to decide on a number.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the plugin_name length to 60

`version` VARCHAR(20) NOT NULL,
`title` VARCHAR(255) NOT NULL,
`description` TEXT NULL,
`link_name` VARCHAR(255) NULL,
`link` VARCHAR(255) NULL,
PRIMARY KEY(`idchange`),
UNIQUE KEY unique_plugin_version_title (`plugin_name`, `version`, `title`)
UNIQUE KEY unique_plugin_version_title (`plugin_name`, `version`, `title`(131))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this like 100 then? For a title it's already very long.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we extend the plugin name to 60, guess we can also lower the title to 100

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the title index limit to 100

Copy link
Contributor

@bx80 bx80 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested the update and it works without issues for me. The plugin_name column length is adjusted and the index is recreated correctly.

@bx80 bx80 merged commit d4b430c into next_release Feb 2, 2022
@bx80 bx80 deleted the fixsqlupdate branch February 2, 2022 21:38
@MatomoForumNotifications

This pull request has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/does-4-71-fix-the-fatal-sql-error-on-upgrade-using-mysql-version-5-5/44656/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants