Support the ongoing development of →
Configuration Database Testing
Last updated 1 year ago.

I use MySQL and migrations in Travis without any issues.

MySQL on Travis binds to and using 'localhost' doesn't work.

You're using .env.testing.php, but you're not telling artisan that it's running in that environment - try adding --env=testing to all the artisan calls.

No need to create a db user, just use root with an empty password.

I wouldn't bother with a shell script personally, just use mysql -e in before_script to create the db.

Here is my known working .travis.yml file - very similar to yours - maybe it'll help:

language: php
 - 5.6
 - 5.5

 - mv travis.env.php .env.testing.php
 - mysql -e 'create database defdx;'
 - composer self-update
 - composer install --dev --prefer-source --no-interaction
 - chmod -R 777 app/storage
 - php artisan migrate:install --env=testing --no-interaction -vvv

 - php artisan migrate --env=testing --no-interaction -vvv
 - php artisan db:seed --env=testing --no-interaction -vvv
 - vendor/bin/codecept run functional
 - php artisan migrate:rollback --env=testing --no-interaction -vvv

 fast_finish: true

My travis.env.php file:

return [
    'DB_HOST'         => '',
    'DB_NAME'         => 'defdx',
    'DB_USER'         => 'root',
    'DB_PASS'         => ''

And the mysql config in the connections array in database.php:

		'mysql' => array(
			'driver'    => 'mysql',
			'host'      => getenv('DB_HOST'),
			'database'  => getenv('DB_NAME'),
			'username'  => getenv('DB_USER'),
			'password'  => getenv('DB_PASS'),
			'charset'   => 'utf8',
			'collation' => 'utf8_unicode_ci',
			'prefix'    => '',

Last updated 9 years ago.

Sign in to participate in this thread!


Your banner here too?

Zarthus zarthus Joined 14 Dec 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.