I'm using Laravel Sail as my development environment. According to the docs,
when the MySQL container is starting, it will ensure a database exists whose name matches the value of your DB_DATABASE environment variable.
This works perfectly for my development environment, but not so much when it comes to testing since my .env.testing defines a separate database, and it seems this database does not get created - when I sail mysql into the container and run show databases; it is not listed. As a result, running sail test fails every test where the database is concerned.
SQLSTATE[HY000] [1045] Access denied for user ...
My .env file contains this:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=dev
My .env.testing file contains this:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME and DB_PASSWORD are the same in both files.
How can I create this database so that it's available when running sail test?
Aucun commentaire:
Enregistrer un commentaire