Adjust field size to keep compatibility with MySQL 5.6

This commit is contained in:
Frédéric Guillot 2018-04-12 15:08:29 -07:00
parent d8c625c856
commit 0e8a94ac42
27 changed files with 59 additions and 39 deletions

View File

@ -16,6 +16,7 @@ php:
env:
- DB=sqlite
- DB=postgres
- DB=mysql
matrix:
fast_finish: true

View File

@ -22,9 +22,28 @@ You might need to run:
REPAIR TABLE table_name;
OPTIMIZE TABLE table_name;
The max length for Mysql 5.6 is 191 for varchar unique keys in utf8mb4
*/
function version_130(PDO $pdo)
{
$pdo->exec("ALTER TABLE `swimlanes` MODIFY `name` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `users` MODIFY `username` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `groups` MODIFY `name` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `links` MODIFY `label` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `tags` MODIFY `name` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `sessions` MODIFY `id` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `project_role_has_restrictions` MODIFY `rule` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `project_has_roles` MODIFY `role` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `project_has_categories` MODIFY `name` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `invites` MODIFY `email` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `invites` MODIFY `token` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `groups` MODIFY `name` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `columns` MODIFY `title` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `column_has_restrictions` MODIFY `rule` VARCHAR(191) NOT NULL");
$pdo->exec("ALTER TABLE `comments` MODIFY `reference` VARCHAR(191) DEFAULT ''");
$pdo->exec("ALTER TABLE `tasks` MODIFY `reference` VARCHAR(191) DEFAULT ''");
$tables = [
'action_has_params',
'actions',

View File

@ -64,7 +64,7 @@ CREATE TABLE `column_has_restrictions` (
`project_id` int(11) NOT NULL,
`role_id` int(11) NOT NULL,
`column_id` int(11) NOT NULL,
`rule` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`rule` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`restriction_id`),
UNIQUE KEY `role_id` (`role_id`,`column_id`,`rule`),
KEY `project_id` (`project_id`),
@ -79,7 +79,7 @@ DROP TABLE IF EXISTS `columns`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `columns` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`title` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`position` int(11) NOT NULL,
`project_id` int(11) NOT NULL,
`task_limit` int(11) DEFAULT '0',
@ -100,7 +100,7 @@ CREATE TABLE `comments` (
`user_id` int(11) DEFAULT '0',
`date_creation` bigint(20) DEFAULT NULL,
`comment` mediumtext COLLATE utf8mb4_unicode_ci,
`reference` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
`reference` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT '',
`date_modification` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
@ -154,7 +154,7 @@ DROP TABLE IF EXISTS `groups`;
CREATE TABLE `groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`external_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@ -163,9 +163,9 @@ DROP TABLE IF EXISTS `invites`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invites` (
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`project_id` int(11) NOT NULL,
`token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`email`,`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -189,7 +189,7 @@ DROP TABLE IF EXISTS `links`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `links` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`label` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`opposite_id` int(11) DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `label` (`label`)
@ -291,7 +291,7 @@ DROP TABLE IF EXISTS `project_has_categories`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `project_has_categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`project_id` int(11) NOT NULL,
`description` mediumtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
@ -360,7 +360,7 @@ DROP TABLE IF EXISTS `project_has_roles`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `project_has_roles` (
`role_id` int(11) NOT NULL AUTO_INCREMENT,
`role` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`role` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`project_id` int(11) NOT NULL,
PRIMARY KEY (`role_id`),
UNIQUE KEY `project_id` (`project_id`,`role`),
@ -387,7 +387,7 @@ CREATE TABLE `project_role_has_restrictions` (
`restriction_id` int(11) NOT NULL AUTO_INCREMENT,
`project_id` int(11) NOT NULL,
`role_id` int(11) NOT NULL,
`rule` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`rule` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`restriction_id`),
UNIQUE KEY `role_id` (`role_id`,`rule`),
KEY `project_id` (`project_id`),
@ -447,7 +447,7 @@ DROP TABLE IF EXISTS `sessions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sessions` (
`id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`id` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`expire_at` int(11) NOT NULL,
`data` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`)
@ -503,7 +503,7 @@ DROP TABLE IF EXISTS `swimlanes`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `swimlanes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`position` int(11) DEFAULT '1',
`is_active` int(11) DEFAULT '1',
`project_id` int(11) DEFAULT NULL,
@ -519,7 +519,7 @@ DROP TABLE IF EXISTS `tags`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`project_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `project_id` (`project_id`,`name`)
@ -622,7 +622,7 @@ CREATE TABLE `tasks` (
`category_id` int(11) DEFAULT '0',
`creator_id` int(11) DEFAULT '0',
`date_modification` int(11) DEFAULT '0',
`reference` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
`reference` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT '',
`date_started` bigint(20) DEFAULT NULL,
`time_spent` float DEFAULT '0',
`time_estimated` float DEFAULT '0',
@ -730,7 +730,7 @@ DROP TABLE IF EXISTS `users`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`username` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`is_ldap_user` tinyint(1) DEFAULT '0',
`name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,

View File

@ -6,7 +6,7 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Category Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="255"', 'tabindex="1"')) ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"', 'tabindex="1"')) ?>
<?= $this->form->label(t('Description'), 'description') ?>
<?= $this->form->textEditor('description', $values, $errors, array('tabindex' => 2)) ?>

View File

@ -5,7 +5,7 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Title'), 'title') ?>
<?= $this->form->text('title', $values, $errors, array('autofocus', 'required', 'maxlength="255"', 'tabindex="1"')) ?>
<?= $this->form->text('title', $values, $errors, array('autofocus', 'required', 'maxlength="191"', 'tabindex="1"')) ?>
<?= $this->form->label(t('Task limit'), 'task_limit') ?>
<?= $this->form->number('task_limit', $values, $errors, array('tabindex="2"')) ?>

View File

@ -6,7 +6,7 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Title'), 'title') ?>
<?= $this->form->text('title', $values, $errors, array('autofocus', 'required', 'maxlength="255"')) ?>
<?= $this->form->text('title', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->form->label(t('Task limit'), 'task_limit') ?>
<?= $this->form->number('task_limit', $values, $errors) ?>

View File

@ -5,7 +5,7 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="255"')) ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->modal->submitButtons() ?>
</form>

View File

@ -8,7 +8,7 @@
<?= $this->form->hidden('external_id', $values) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="255"')) ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->modal->submitButtons() ?>
</form>

View File

@ -5,7 +5,7 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="255"')) ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->modal->submitButtons() ?>
</form>

View File

@ -5,7 +5,7 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="255"')) ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->modal->submitButtons() ?>
</form>

View File

@ -5,7 +5,7 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="255"', 'tabindex="1"')) ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"', 'tabindex="1"')) ?>
<?= $this->form->label(t('Description'), 'description') ?>
<?= $this->form->textEditor('description', $values, $errors, array('tabindex' => 2)) ?>

View File

@ -6,7 +6,7 @@
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="255"', 'tabindex="1"')) ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"', 'tabindex="1"')) ?>
<?= $this->form->label(t('Description'), 'description') ?>
<?= $this->form->textEditor('description', $values, $errors, array('tabindex' => 2)) ?>

View File

@ -6,7 +6,7 @@
<?= $this->form->hidden('project_id', $values) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="255"')) ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->modal->submitButtons() ?>
</form>

View File

@ -7,7 +7,7 @@
<?= $this->form->hidden('project_id', $values) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="255"')) ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->modal->submitButtons() ?>
</form>

View File

@ -10,7 +10,7 @@
<legend><?= t('Profile') ?></legend>
<?= $this->form->label(t('Username'), 'username') ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="255"')) ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors) ?>

View File

@ -9,7 +9,7 @@
<legend><?= t('Profile') ?></legend>
<?= $this->form->label(t('Username'), 'username') ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="255"')) ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors) ?>

View File

@ -8,7 +8,7 @@
<fieldset>
<legend><?= t('Profile') ?></legend>
<?= $this->form->label(t('Username'), 'username') ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1 && !$this->user->isAdmin() ? 'readonly' : '', 'maxlength="255"')) ?>
<?= $this->form->text('username', $values, $errors, array('autofocus', 'required', isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1 && !$this->user->isAdmin() ? 'readonly' : '', 'maxlength="191"')) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array($this->user->hasAccess('UserModificationController', 'show/edit_name') ? '' : 'readonly')) ?>

View File

@ -37,7 +37,7 @@ class AuthValidator extends BaseValidator
{
$v = new Validator($values, array(
new Validators\Required('username', t('The username is required')),
new Validators\MaxLength('username', t('The maximum length is %d characters', 255), 255),
new Validators\MaxLength('username', t('The maximum length is %d characters', 191), 191),
new Validators\Required('password', t('The password is required')),
));

View File

@ -68,7 +68,7 @@ class CategoryValidator extends BaseValidator
return array(
new Validators\Integer('id', t('The id must be an integer')),
new Validators\Integer('project_id', t('The project id must be an integer')),
new Validators\MaxLength('name', t('The maximum length is %d characters', 255), 255)
new Validators\MaxLength('name', t('The maximum length is %d characters', 191), 191)
);
}
}

View File

@ -69,7 +69,7 @@ class ColumnValidator extends BaseValidator
new Validators\Integer('task_limit', t('This value must be an integer')),
new Validators\GreaterThan('task_limit', t('This value must be greater than %d', -1), -1),
new Validators\Required('title', t('The title is required')),
new Validators\MaxLength('title', t('The maximum length is %d characters', 255), 255),
new Validators\MaxLength('title', t('The maximum length is %d characters', 191), 191),
);
}
}

View File

@ -91,7 +91,7 @@ class CommentValidator extends BaseValidator
new Validators\Integer('id', t('This value must be an integer')),
new Validators\Integer('task_id', t('This value must be an integer')),
new Validators\Integer('user_id', t('This value must be an integer')),
new Validators\MaxLength('reference', t('The maximum length is %d characters', 255), 255),
new Validators\MaxLength('reference', t('The maximum length is %d characters', 191), 191),
new Validators\Required('comment', t('Comment is required'))
);
}

View File

@ -62,7 +62,7 @@ class GroupValidator extends BaseValidator
{
return array(
new Validators\Required('name', t('The name is required')),
new Validators\MaxLength('name', t('The maximum length is %d characters', 255), 255),
new Validators\MaxLength('name', t('The maximum length is %d characters', 191), 191),
new Validators\Unique('name', t('The name must be unique'), $this->db->getConnection(), GroupModel::TABLE, 'id'),
new Validators\MaxLength('external_id', t('The maximum length is %d characters', 255), 255),
new Validators\Integer('id', t('This value must be an integer')),

View File

@ -55,7 +55,7 @@ class PasswordResetValidator extends BaseValidator
$v = new Validator($values, array(
new Validators\Required('captcha', t('This value is required')),
new Validators\Required('username', t('The username is required')),
new Validators\MaxLength('username', t('The maximum length is %d characters', 255), 255),
new Validators\MaxLength('username', t('The maximum length is %d characters', 191), 191),
));
return array(

View File

@ -68,7 +68,7 @@ class SwimlaneValidator extends BaseValidator
return array(
new Validators\Integer('id', t('The id must be an integer')),
new Validators\Integer('project_id', t('The project id must be an integer')),
new Validators\MaxLength('name', t('The maximum length is %d characters', 255), 255)
new Validators\MaxLength('name', t('The maximum length is %d characters', 191), 191)
);
}
}

View File

@ -70,7 +70,7 @@ class TagValidator extends BaseValidator
return array(
new Validators\Required('project_id', t('Field required')),
new Validators\Required('name', t('Field required')),
new Validators\MaxLength('name', t('The maximum length is %d characters', 255), 255),
new Validators\MaxLength('name', t('The maximum length is %d characters', 191), 191),
);
}
}

View File

@ -41,7 +41,7 @@ class TaskValidator extends BaseValidator
new Validators\Integer('recurrence_status', t('This value must be an integer')),
new Validators\Integer('priority', t('This value must be an integer')),
new Validators\MaxLength('title', t('The maximum length is %d characters', 65535), 65535),
new Validators\MaxLength('reference', t('The maximum length is %d characters', 255), 255),
new Validators\MaxLength('reference', t('The maximum length is %d characters', 191), 191),
new Validators\Date('date_due', t('Invalid date'), $this->dateParser->getParserFormats()),
new Validators\Date('date_started', t('Invalid date'), $this->dateParser->getParserFormats()),
new Validators\Numeric('time_spent', t('This value must be numeric')),

View File

@ -24,7 +24,7 @@ class UserValidator extends BaseValidator
{
return array(
new Validators\MaxLength('role', t('The maximum length is %d characters', 25), 25),
new Validators\MaxLength('username', t('The maximum length is %d characters', 255), 255),
new Validators\MaxLength('username', t('The maximum length is %d characters', 191), 191),
new Validators\Unique('username', t('This username is already taken'), $this->db->getConnection(), UserModel::TABLE, 'id'),
new Validators\Email('email', t('Email address invalid')),
new Validators\Integer('is_ldap_user', t('This value must be an integer')),