12
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Laravel 5.2] Laravelでtest用DBにmigrateする方法

Posted at

Laravel入門者の備忘録です。

テスト用DBの設定を記載します。

mysqlでもpostgresでもsqliteでもなんでもいいdせうが、surfixに _testingをつけておくとわかりやすいです。

config/database.php
 'mysql_testing' => [
   'driver'    => 'mysql',
   'host'      => env('TESTING_DB_HOST', 'localhost'),
   'database'  => env('TESTING_DB_DATABASE', 'forge'),
   'username'  => env('TESTING_DB_USERNAME', 'forge'),
   'password'  => env('TESTING_DB_PASSWORD', ''),
   'charset'   => 'utf8',
   'collation' => 'utf8_unicode_ci',
   'prefix'    => '',
   'strict'    => false,
  ],

環境変数の設定

.env
TESTING_DB_HOST=localhost
TESTING_DB_DATABASE=homestead_testing
TESTING_DB_USERNAME=homestead
TESTING_DB_PASSWORD=secret

command

php artisan migrate --database=mysql_testing

参考

12
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?