I'm using Symfony 4 with flex and tried to make some translation tables with the KNP Labs - Doctrine Behaviors but the index name auto generated by Symfony is too long for MariaDb. At least I understand this from the error:
In AbstractMySQLDriver.php line 125:
An exception occurred while executing
CREATE TABLE app_menu_trans (
id INT AUTO_INCREMENT NOT NULL,
translatable_id INT DEFAULT NULL,
name VARCHAR(255 ) NOT NULL,
locale VARCHAR(255) NOT NULL,
INDEX IDX_B79696A62C2AC5D3 (trans latable_id),
UNIQUE INDEX app_menu_trans_unique_translation (translatable_id, locale),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long; max key length is 767 bytes
In PDOConnection.php line 109:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long; max key length is 767 bytes
In PDOConnection.php line 107:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long; max key length is 767 bytes
Something's fishy here, because MariaDb specs say that :
Databases, tables, columns, indexes, constraints, stored routines, triggers, events, views, tablespaces, servers and log file groups have an maximum length of 64 characters.
I'm not advanced enough to understand what is wrong and how to get around it.
My Translation Table class below:
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
/**
* @ORM\Table(name="app_menu_trans")
* @ORM\Entity
*/
class MenuTranslation
{
use ORMBehaviors\Translatable\Translation;
/**
* @var string
*
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*
* @return MenuTranslationTranslation
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
}