symfony / orm-pack

A Symfony Pack for Doctrine ORM
MIT License
1.82k stars 18 forks source link

Symfony 6.4 SQLite DB error SQLitePlatform::getCreateDatabaseSQL caused by doctrine/dbal 4.0 #42

Closed avinsol closed 7 months ago

avinsol commented 7 months ago

Hi, I installed a fresh symfony/skeleton:"6.4.*" project for an api app, then I required symfony/orm-pack and set the database in .env file as sqlite: DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"

On executing the command console doctrine:database:create it throws the error: Could not create database /home/user/skeleton-api/var/data.db for connection named default Operation "Doctrine\DBAL\Platforms\SQLitePlatform::getCreateDatabaseSQL" is not supported by platform. After a lot of test and research I found that the doctrine/orm requires the doctrine/dbal version 4.0.0 and it seems nowadays it may be on development state without sqlite support or something similar, in fact at the doctrine website says that this version is not released yet.

Well, to solve this I made the following steps:

After that the console doctrine:database:create runs well with no error and the database is created. I don't know whether I will have more problems from here, but I liked to share my experience if any one has the same issue. Also, it will be good if someone can modify the doctrine/orm dependencies to <4.0 version of doctrine/dbal while it is not stable version with sqlite support, it will be fully appreciate. Thanks for your work. Avinsol.

nicolas-grekas commented 7 months ago

/cc @derrabus in case you can have a look before I do? :pray:

derrabus commented 7 months ago

On executing the command console doctrine:database:create

Why would you do that on an SQLite database?

derrabus commented 7 months ago

Either way, I think we can close this issue.

The command is part of https://github.com/doctrine/DoctrineBundle. Please open an issue there if you want to discuss it further.

olberger commented 2 weeks ago

FWIW, I encountered this error while upgrading a project from 6.3 to 6.4, and figured out that my composer.json lacked a rule that seems to be now by default when creating a LTS project with symfony new --version=lts:

"doctrine/dbal": "^3",

Hope this helps,