reduce field size to 150 chars to prevent index out of length (#1031)
This commit is contained in:
@@ -14,6 +14,9 @@ Perform EACH version specific task between your version and the new one, otherwi
|
||||
|
||||
- Deleted timezone conversion command. If you are still using 0.7 or below, you need to upgrade to 1.1 before upgrading to this version.
|
||||
- Minimum password length raised from 5 to 8 character (applies only for password changes and new users)
|
||||
- Maximum customer name length lowered to 150 character
|
||||
- Maximum project name length lowered to 150 character
|
||||
- Maximum activity name length lowered to 150 character
|
||||
|
||||
## [1.1](https://github.com/kevinpapst/kimai2/releases/tag/1.1)
|
||||
|
||||
|
||||
@@ -50,16 +50,18 @@ class Activity implements EntityWithMetaFields
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=255, nullable=false)
|
||||
* Do not increase length to more than 190 chars, otherwise "Index column size too large." will be triggered.
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=150, nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(min=2, max=255)
|
||||
* @Assert\Length(min=2, max=150)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
|
||||
* @ORM\Column(name="comment", type="text", nullable=true)
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
|
||||
@@ -40,9 +40,11 @@ class Customer implements EntityWithMetaFields
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=255, nullable=false)
|
||||
* Do not increase length to more than 190 chars, otherwise "Index column size too large." will be triggered.
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=150, nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(min=2, max=255)
|
||||
* @Assert\Length(min=2, max=150)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
@@ -50,13 +52,14 @@ class Customer implements EntityWithMetaFields
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="number", type="string", length=50, nullable=true)
|
||||
* @Assert\Length(max=50)
|
||||
*/
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
|
||||
* @ORM\Column(name="comment", type="text", nullable=true)
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
@@ -72,6 +75,7 @@ class Customer implements EntityWithMetaFields
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="company", type="string", length=255, nullable=true)
|
||||
* @Assert\Length(max=255)
|
||||
*/
|
||||
private $company;
|
||||
|
||||
@@ -79,13 +83,14 @@ class Customer implements EntityWithMetaFields
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="contact", type="string", length=255, nullable=true)
|
||||
* @Assert\Length(max=255)
|
||||
*/
|
||||
private $contact;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="address", type="text", length=65535, nullable=true)
|
||||
* @ORM\Column(name="address", type="text", nullable=true)
|
||||
*/
|
||||
private $address;
|
||||
|
||||
@@ -94,6 +99,7 @@ class Customer implements EntityWithMetaFields
|
||||
*
|
||||
* @ORM\Column(name="country", type="string", length=2, nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(max=2)
|
||||
*/
|
||||
private $country;
|
||||
|
||||
@@ -102,6 +108,7 @@ class Customer implements EntityWithMetaFields
|
||||
*
|
||||
* @ORM\Column(name="currency", type="string", length=3, nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(max=3)
|
||||
*/
|
||||
private $currency = self::DEFAULT_CURRENCY;
|
||||
|
||||
@@ -109,6 +116,7 @@ class Customer implements EntityWithMetaFields
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="phone", type="string", length=255, nullable=true)
|
||||
* @Assert\Length(max=255)
|
||||
*/
|
||||
private $phone;
|
||||
|
||||
@@ -116,6 +124,7 @@ class Customer implements EntityWithMetaFields
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="fax", type="string", length=255, nullable=true)
|
||||
* @Assert\Length(max=255)
|
||||
*/
|
||||
private $fax;
|
||||
|
||||
@@ -123,13 +132,17 @@ class Customer implements EntityWithMetaFields
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="mobile", type="string", length=255, nullable=true)
|
||||
* @Assert\Length(max=255)
|
||||
*/
|
||||
private $mobile;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* Limited via RFC to 254 chars
|
||||
*
|
||||
* @ORM\Column(name="email", type="string", length=255, nullable=true)
|
||||
* @Assert\Length(max=254)
|
||||
*/
|
||||
private $email;
|
||||
|
||||
@@ -137,14 +150,18 @@ class Customer implements EntityWithMetaFields
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="homepage", type="string", length=255, nullable=true)
|
||||
* @Assert\Length(max=255)
|
||||
*/
|
||||
private $homepage;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="timezone", type="string", length=255, nullable=false)
|
||||
* Length was determined by a MySQL column via "use mysql;describe time_zone_name;"
|
||||
*
|
||||
* @ORM\Column(name="timezone", type="string", length=64, nullable=false)
|
||||
* @Assert\NotBlank()
|
||||
* @Assert\Length(max=64)
|
||||
*/
|
||||
private $timezone;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class InvoiceTemplate
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="address", type="text", length=65535, nullable=true)
|
||||
* @ORM\Column(name="address", type="text", nullable=true)
|
||||
*/
|
||||
private $address;
|
||||
|
||||
@@ -105,7 +105,7 @@ class InvoiceTemplate
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="payment_terms", type="text", length=65535, nullable=true)
|
||||
* @ORM\Column(name="payment_terms", type="text", nullable=true)
|
||||
*/
|
||||
private $paymentTerms;
|
||||
|
||||
|
||||
@@ -49,9 +49,11 @@ class Project implements EntityWithMetaFields
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=255, nullable=false)
|
||||
* Do not increase length to more than 190 chars, otherwise "Index column size too large." will be triggered.
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=150, nullable=false)
|
||||
* @Assert\NotNull()
|
||||
* @Assert\Length(min=2, max=255)
|
||||
* @Assert\Length(min=2, max=150)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
@@ -66,7 +68,7 @@ class Project implements EntityWithMetaFields
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
|
||||
* @ORM\Column(name="comment", type="text", nullable=true)
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ class Timesheet implements EntityWithMetaFields
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="description", type="text", length=65535, nullable=true)
|
||||
* @ORM\Column(name="description", type="text", nullable=true)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
|
||||
@@ -50,15 +50,27 @@ final class Version20190706224219 extends AbstractMigration
|
||||
$timesheet->addIndex(['start_time', 'end_time', 'user'], 'IDX_4F60C6B1502DF587415614018D93D649');
|
||||
|
||||
$activity = $schema->getTable('kimai2_activities');
|
||||
$name = $activity->getColumn('name');
|
||||
if ($name->getLength() !== 150) {
|
||||
$name->setLength(150);
|
||||
}
|
||||
$activity->addIndex(['visible', 'project_id'], 'IDX_8811FE1C7AB0E859166D1F9C');
|
||||
$activity->addIndex(['visible', 'project_id', 'name'], 'IDX_8811FE1C7AB0E859166D1F9C5E237E06');
|
||||
$activity->addIndex(['visible', 'name'], 'IDX_8811FE1C7AB0E8595E237E06');
|
||||
|
||||
$project = $schema->getTable('kimai2_projects');
|
||||
$name = $project->getColumn('name');
|
||||
if ($name->getLength() !== 150) {
|
||||
$name->setLength(150);
|
||||
}
|
||||
$project->addIndex(['customer_id', 'visible', 'name'], 'IDX_407F12069395C3F37AB0E8595E237E06');
|
||||
$project->addIndex(['customer_id', 'visible', 'id'], 'IDX_407F12069395C3F37AB0E859BF396750');
|
||||
|
||||
$customer = $schema->getTable('kimai2_customers');
|
||||
$name = $customer->getColumn('name');
|
||||
if ($name->getLength() !== 150) {
|
||||
$name->setLength(150);
|
||||
}
|
||||
$customer->addIndex(['visible'], 'IDX_5A9760447AB0E859');
|
||||
}
|
||||
|
||||
@@ -68,13 +80,16 @@ final class Version20190706224219 extends AbstractMigration
|
||||
$activity->dropIndex('IDX_8811FE1C7AB0E859166D1F9C');
|
||||
$activity->dropIndex('IDX_8811FE1C7AB0E859166D1F9C5E237E06');
|
||||
$activity->dropIndex('IDX_8811FE1C7AB0E8595E237E06');
|
||||
$activity->getColumn('name')->setLength(255);
|
||||
|
||||
$customer = $schema->getTable('kimai2_customers');
|
||||
$customer->dropIndex('IDX_5A9760447AB0E859');
|
||||
$customer->getColumn('name')->setLength(255);
|
||||
|
||||
$project = $schema->getTable('kimai2_projects');
|
||||
$project->dropIndex('IDX_407F12069395C3F37AB0E8595E237E06');
|
||||
$project->dropIndex('IDX_407F12069395C3F37AB0E859BF396750');
|
||||
$project->getColumn('name')->setLength(255);
|
||||
|
||||
$timesheet = $schema->getTable('kimai2_timesheet');
|
||||
$timesheet->dropIndex('IDX_4F60C6B18D93D649502DF587');
|
||||
|
||||
78
src/Migrations/Version20190813162649.php
Normal file
78
src/Migrations/Version20190813162649.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use App\Doctrine\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Changing column sizes to prevent index length errors.
|
||||
*
|
||||
* @version 1.2
|
||||
*/
|
||||
final class Version20190813162649 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Changing column sizes to prevent index length errors';
|
||||
}
|
||||
|
||||
protected function isSupportingForeignKeys(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isTransactional(): bool
|
||||
{
|
||||
if ($this->isPlatformSqlite()) {
|
||||
// does fail if we use transactions, as tables are re-created and foreign keys would fail
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$activity = $schema->getTable('kimai2_activities');
|
||||
$name = $activity->getColumn('name');
|
||||
if ($name->getLength() !== 150) {
|
||||
$name->setLength(150);
|
||||
}
|
||||
|
||||
$project = $schema->getTable('kimai2_projects');
|
||||
$name = $project->getColumn('name');
|
||||
if ($name->getLength() !== 150) {
|
||||
$name->setLength(150);
|
||||
}
|
||||
|
||||
$customer = $schema->getTable('kimai2_customers');
|
||||
$name = $customer->getColumn('name');
|
||||
if ($name->getLength() !== 150) {
|
||||
$name->setLength(150);
|
||||
}
|
||||
$customer->getColumn('timezone')->setLength(64);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$activity = $schema->getTable('kimai2_activities');
|
||||
$activity->getColumn('name')->setLength(255);
|
||||
|
||||
$project = $schema->getTable('kimai2_projects');
|
||||
$project->getColumn('name')->setLength(255);
|
||||
|
||||
$customer = $schema->getTable('kimai2_customers');
|
||||
$customer->getColumn('name')->setLength(255);
|
||||
$customer->getColumn('timezone')->setLength(255);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user