In my Linux server, I have MariaDB version 10.0 which does not support json type (supported until version 10.2) and I can't update it because it is not released in official ubuntu repository.
When I run the command doctrine:migration:migrate
for creating tables I get a syntax error from MariaDB for json type
MariaDB: 10.0.34 - PHP: 7.1 - Symfony: 4.0.6
How do I solve this issue?
You should update it and please stop using the default distro repo for MariaDB. As they have there own that is kept updated,
https://downloads.mariadb.org/mariadb/repositories/#mirror=exascale&distro=Ubuntu
The only thing that will differ from there guide is,
sudo apt update
sudo apt install mariadb-server
Will become
sudo apt update
sudo apt upgrade mariadb-server
once you do that you should be good to go.
Copy of information from that link
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386] http://mirror.sax.uk.as61049.net/mariadb/repo/10.2/ubuntu artful main'
sudo apt update
sudo apt install mariadb-server
The problem is that Doctrine is expecting MariaDB 10.2+, but there have been problems getting the latest MariaDB versions into repos (Arch is still at 10.1).
The solution is here:
https://symfony.com/doc/current/reference/configuration/doctrine.html#doctrine-dbal-configuration
Just configure server_version
in config/packages/doctrine.yml
to:
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: 'mariadb-10.1.34'
...
Just replace the version with your version number which you can get with
$ mysql --version
* @ORM\Column(name="roles", type="string")
private $usuarioRoles;
public function getRoles(): array {
$roles = explode(",",$this->usuarioRoles);
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self {
$this->usuarioRol = implode(",",$roles);
return $this;
}