I am trying make user via CLI: (symfony doc)
php bin/console make:user
This command create User.php entity which implements UserInterface.
But after command:
php bin/console doctrine:schema:update --force
I get errors:
In AbstractMySQLDriver.php line 79:
An exception occurred while executing 'CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(18 0) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (emai l), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB':
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the ma nual that corresponds to your MariaDB server version for the right syntax to use near 'JSON NOT NULL, pass word VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C7' at line 1
In PDOConnection.php line 90:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the ma nual that corresponds to your MariaDB server version for the right syntax to use near 'JSON NOT NULL, pass word VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C7' at line 1
In PDOConnection.php line 88:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the ma nual that corresponds to your MariaDB server version for the right syntax to use near 'JSON NOT NULL, pass word VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C7' at line 1
EDIT:
Info about sql:
Server type: MariaDB
Server version: 10.1.31-MariaDB - mariadb.org binary distribution
Protocol version: 10
JSON Type is an unknown type for your MariaDB database version (cf type documentation). Doctrine creates a bad migration script, because it didn't know which version you're using.
Configure server_version
in config/packages/doctrine.yml
to:
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: 'XXXX'
...
Replace X by your version, prefixed by mariadb-
as mentioned in documentation. So DoctrineBundle will know that JSON is not supported and will replace by another type.