doctrine / data-fixtures

Doctrine2 ORM Data Fixtures Extensions
http://www.doctrine-project.org
MIT License
2.77k stars 224 forks source link

no such table while loading fixtures with SQLite #321

Closed thomas-hiron closed 4 years ago

thomas-hiron commented 4 years ago

I'm trying to run my tests with SQLite, I'm all set with docker on my computer, everything is working fine. But when I'm running them in the CI, fixtures can't load. I get an error:
SQLSTATE[HY000]: General error: 1 no such table
The table causing this error is not always the same (alterning between two tables).

I dumped sql queries and there is a query CREATE TABLE for this table.

Here is the CI output:
image

And here is the doctrine configuration for test env:

doctrine:
    dbal:
        connections:
            pilote:
                url:            '%env(resolve:DATABASE_SQLITE_URL)%'
                server_version: '3.28.0'
                charset:        utf8mb4

The env var is: sqlite:///%kernel.project_dir%/databases/pilote.db

Here is the basic doctrine configuration:

doctrine:
    dbal:
        default_connection: pilote
        connections:
            pilote:
                url:            '%env(DATABASE_PILOTE_URL)%'
                wrapper_class:  'App\Pilote\Connection\PiloteConnection'
                server_version: 'mariadb-10.1.16'
                charset:        UTF8

Why I have this behavior only in the CI and how can I fix it?

Thanks by advance!

Ocramius commented 4 years ago

General error: 1 no such table

doctrine/data-fixtures doesn't really concern itself with schema structure: it assumes that your schema is already in place.

You have to have a running DB with the generated/imported/migrated schema in it first.

thomas-hiron commented 4 years ago

I don't understand. The DB and each table are created with doctrine:schema:update --force.
Everything is working fine when I chain those commands on my computer.

Ocramius commented 4 years ago

Maybe in CI you are connecting to a different DB due to parsed environment variables?

thomas-hiron commented 4 years ago

I'm using .env.dist where the env var is the same as in my .env file :/
I'll try to change the path but I'm sure that the dir exists!

thomas-hiron commented 4 years ago

That was indeed a misconfiguration, the db was created only in the running container, so not available for the next command..