Skip to content

Commit c0f3ea1

Browse files
committed
Merge pull request #6 from aMoniker/master
Call migrate:install before attempting migrate:refresh
2 parents 788a7a9 + 455362c commit c0f3ea1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

spec/PhpSpec/Laravel/Util/LaravelSpec.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function it_allows_the_env_to_be_set_to_anything(Application $app)
2929

3030
function it_will_run_migrations_if_told_to(Application $app, Console $console)
3131
{
32+
$console->call('migrate:install')->shouldBeCalled();
3233
$console->call('migrate:refresh')->shouldBeCalled();
3334
$app->make('artisan')->shouldBeCalled();
3435
$app->make('artisan')->willReturn($console);

src/PhpSpec/Laravel/Util/Laravel.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php namespace PhpSpec\Laravel\Util;
22

33
use ErrorException;
4+
use Illuminate\Database\QueryException;
45
use Illuminate\Foundation\Application;
56

67
/**
@@ -75,7 +76,15 @@ public function refreshApplication($app = null)
7576
$this->app->boot();
7677

7778
if ($this->migrateDatabase) {
78-
$this->app->make('artisan')->call('migrate:refresh');
79+
$artisan = $this->app->make('artisan');
80+
81+
try {
82+
$artisan->call('migrate:install');
83+
} catch (QueryException $e) {
84+
// migration table is already installed
85+
}
86+
87+
$artisan->call('migrate:refresh');
7988
}
8089
}
8190

0 commit comments

Comments
 (0)