Travis-CI: Running `php artisan migrate --no-interaction -vvv` displays no output, no log files created.


I'm running across an issue where none of the php artisan migrate commands give any output when validating the commit using Travis CI.

My travis.yml file:

language: php
  - 5.6
  - 5.5
  - 5.4

  - DB=mysql

  - mv example.env.php .env.testing.php
  - travis_retry composer self-update
  - travis_retry composer install --prefer-source --no-interaction --dev
  - chmod -R 777 app/storage
  - chmod +x; ./
  - php artisan migrate:install --no-interaction -vvv

  - phpunit --verbose
  - php artisan migrate --no-interaction -vvv
  - php artisan migrate:rollback --no-interaction -vvv

  - ls -laR app/storage
  - cat app/storage/logs/*

    - [email protected]
      - ""
      - "%{repository}#%{build_number} (%{branch} - %{commit}) %{author}: %{message} - %{build_url}"
  on_failure: always
  on_success: change

Shell script for creating the database user:


echo "DB=$DB"

if [[ "$DB" == "mysql" ]]; then
  mysql --execute "CREATE DATABASE IF NOT EXISTS \`it-ao-alfa\`;" --user=root
  mysql --execute "USE \`it-ao-alfa\`;" --user=root
  mysql --execute "CREATE USER 'it-ao-alfa'@'localhost';" --user=root
  mysql --execute "GRANT ALL PRIVILEGES ON \`it-ao-alfa\`.* TO 'it-ao-alfa'@'localhost';" --user=root
  mysql --execute "FLUSH PRIVILEGES;" --user=root

Example Tests:

Where travis delivers the following output:

0.15s $ php artisan migrate --no-interaction -vvv
The command "php artisan migrate --no-interaction -vvv" exited with 0.
0.15s $ php artisan migrate:rollback --no-interaction -vvv
The command "php artisan migrate:rollback --no-interaction -vvv" exited with 0.

Regardless of what I even attempt, there is no output shown. No error logs are created, there are definitely migrations, and it just doesn't appear to be working. I have tried everything I could think of, but I fear I am at a loss. Locally everything works, I have tried building it from the ground up with a new vps and it just works. Could there be an issue with Travis, or is my configuration for the testing environment wrong? am I not making the databases correctly with the shell script? I have no idea.

Which is where I was hoping that the people of the internet could help find out what is wrong, or give me some suggestions on how to accurately troubleshoot this issue.

Thanks for looking into this issue, and if you have any suggestions, do let me know!

pagnificence replied 2 years 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'    => '',

Sign in to participate in this thread!

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