skinnyvin's avatar

Migrations not peristing

I am following the TDD Forum series and I think I must've missed something configuration wise.

If I run :

php artisan migrate

My tables migrate, but they do not persist. Soon after the tables are deleted. My .envs pecifies mysql. Should I have config somewhere for the tests to use an sqlite db? Not sure what I have missed.

THanks

0 likes
7 replies
cmgmyr's avatar

Usually, your test environment variables are in your phpunit.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
    ...
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>
    </php>
</phpunit>

The php artisan migrate will migrate your local dev environment which will read from the .env file

skinnyvin's avatar

Thank you for the reply. Mine is as per the above. So still puzzling.

nick.a's avatar

Well if your phpunit.xml is as shown, what does your .env file look like?

skinnyvin's avatar

Pretty much standard out of the box settings:

APP_ENV=local
APP_KEY=base64:+iATJXbjB01O+lrCUXsYEZm06MABOELJN3yp/uW02Fg=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=xyz
DB_USERNAME=homestead
DB_PASSWORD=xyz

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

nick.a's avatar

Well I can't think of anything unless you are using DatabaseTransactions somewhere and it's rolling back your changes. The best thing to do would be open up Jeffrey's github page for this series and review the code in comparison with yours and see if you can identify differences.

Benja's avatar

is there any error outputted??

skinnyvin's avatar

No errors other than what you would expect if the db isn't there. I'll check for DatabaseTransactions and compare with the GitHub code.

Thanks

Please or to participate in this conversation.