Skip to content

Commit 0a15097

Browse files
committed
Handle database sync with unrun migration.
1 parent 9415fd3 commit 0a15097

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Diff for: src/DatabaseNomadicRepository.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public function log($file, $batch, $params = [])
4141
*/
4242
public function getProperties($migrationFileName)
4343
{
44-
return get_object_vars($this->table()->where('migration', $migrationFileName)->first());
44+
$existingMigration = $this->table()->where('migration', $migrationFileName)->first();
45+
if (is_object($existingMigration)) {
46+
return get_object_vars($existingMigration);
47+
}
48+
return [];
4549
}
4650
}

Diff for: tests/DatabaseNomadicRepositoryTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ public function testGetProperties()
5050
$this->assertNotEmpty($this->repo->getProperties($fileName));
5151
}
5252

53+
public function testGetPropertiesWithUnRunMigration()
54+
{
55+
$fileName = '2018_04_21_Migration';
56+
57+
$collection = new Collection();
58+
59+
$this->repo->expects($this->once())
60+
->method('table')
61+
->willReturn($collection);
62+
63+
$this->assertEmpty($this->repo->getProperties($fileName));
64+
}
65+
5366
public function tearDown()
5467
{
5568
unset($this->repo);

0 commit comments

Comments
 (0)