Skip to content

Commit

Permalink
Use created_at column on migrations.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickescobedo committed Oct 11, 2024
1 parent c320c96 commit a9fe9ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getMigrationBatches()
*/
public function log($file, $batch)
{
$record = ['migration' => $file, 'batch' => $batch];
$record = ['migration' => $file, 'batch' => $batch, 'created_at' => now()];

$this->table()->insert($record);
}
Expand Down Expand Up @@ -169,7 +169,7 @@ public function createRepository()
$table->increments('id');
$table->string('migration');
$table->integer('batch');
// $table->dateTime('executed_at');
$table->dateTime('created_at');
});
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Database/DatabaseMigrationRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public function testGetLastMigrationsGetsAllMigrationsWithTheLatestBatchNumber()

public function testLogMethodInsertsRecordIntoMigrationTable()
{
// Carbon::setTestNow(now());
Carbon::setTestNow(now());

$repo = $this->getRepository();
$query = m::mock(stdClass::class);
$connectionMock = m::mock(Connection::class);
$repo->getConnectionResolver()->shouldReceive('connection')->with(null)->andReturn($connectionMock);
$repo->getConnection()->shouldReceive('table')->once()->with('migrations')->andReturn($query);
$query->shouldReceive('insert')->once()->with(['migration' => 'bar', 'batch' => 1]);
$query->shouldReceive('insert')->once()->with(['migration' => 'bar', 'batch' => 1, 'created_at' => now()]);
$query->shouldReceive('useWritePdo')->once()->andReturn($query);

$repo->log('bar', 1);
Expand Down

0 comments on commit a9fe9ab

Please sign in to comment.