Support the ongoing development of Laravel.io →
Configuration Database Testing
Last updated 2 years ago.
0

I use MySQL and migrations in Travis without any issues.

MySQL on Travis binds to 127.0.0.1 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
php:
 - 5.6
 - 5.5

before_script:
 - 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

script:
 - 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

matrix:
 fast_finish: true

My travis.env.php file:

<?php
return [
    'DB_HOST'         => '127.0.0.1',
    '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.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Zarthus zarthus Joined 14 Dec 2014

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.