Just found out doctrine:schema:validate
fires an error:
[ERROR] The database schema is not in sync with the current mapping file.
So I tried to doctrine:schema:update --force --complete --dump-sql
which was successful:
The following SQL statements will be executed:
ALTER TABLE user CHANGE last_login `last_login` DATETIME DEFAULT NULL;
Updating database schema...
1 query was executed
[OK] Database schema updated successfully!
But if I run doctrine:schema:validate
again it throws the same error regarding schema not in sync.
I have checked Database table field definition and it looks good:
`last_login` datetime DEFAULT NULL
And this is how a column is defined:
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $last_login;
I have found this: https://github.com/doctrine/dbal/pull/2825
Any ideas?
In your config.yml
or doctrine.yaml
(dependending on the Symfony's version), set proper server version of your database server. Eg:
doctrine:
# …
dbal:
# …
server_version: mariadb-10.2.15
Note the mariadb
prefix.
It seems that Doctrine has problems determining the correct MySQL API version when trying to derive the server version from a MariaDB installation.
It may help to define a MySQL version number in your configuration. It did for me in several projects, eg when using MariaDB on Debian Stretch.
# app/config/config.yml
doctrine:
# …
dbal:
# …
server_version: 5.7
This will have the effect that Doctrine skips the auto-detection of the MySQL version and uses a recent API.
I changed the DATABASE_URL in my .env.local and it worked. Before (did not work)
DATABASE_URL=mysql://root:password@127.0.0.1:3306/db?serverVersion=10.4.12
After (worked finally)
DATABASE_URL=mysql://root:password@127.0.0.1:3306/db?serverVersion=mariadb-10.4.12
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.