diff --git a/src/Console/FreshCommand.php b/src/Console/FreshCommand.php index 2ed3177..db29fe4 100644 --- a/src/Console/FreshCommand.php +++ b/src/Console/FreshCommand.php @@ -35,7 +35,7 @@ public function handle( $indexManager->drop('*'); - $migrationRepository->truncate(); + $migrationRepository->deleteAll(); $migrator->migrateAll(); diff --git a/src/Repositories/MigrationRepository.php b/src/Repositories/MigrationRepository.php index 5876383..c13ac41 100644 --- a/src/Repositories/MigrationRepository.php +++ b/src/Repositories/MigrationRepository.php @@ -48,6 +48,14 @@ public function delete(string $fileName): bool ->delete(); } + public function deleteAll(): void + { + $this->table()->delete(); + } + + /** + * @deprecated + */ public function truncate(): void { $this->table()->truncate(); diff --git a/tests/Integration/Console/FreshCommandTest.php b/tests/Integration/Console/FreshCommandTest.php index c933b52..88defec 100644 --- a/tests/Integration/Console/FreshCommandTest.php +++ b/tests/Integration/Console/FreshCommandTest.php @@ -63,7 +63,7 @@ public function test_does_nothing_if_migrator_is_not_ready(): void $this->migrationRepository ->expects($this->never()) - ->method('truncate'); + ->method('deleteAll'); $this->migrator ->expects($this->never()) @@ -91,7 +91,7 @@ public function test_drops_indicies_and_migration(): void $this->migrationRepository ->expects($this->once()) - ->method('truncate'); + ->method('deleteAll'); $this->migrator ->expects($this->once()) diff --git a/tests/Integration/Repositories/MigrationRepositoryTest.php b/tests/Integration/Repositories/MigrationRepositoryTest.php index 6792351..ba43086 100644 --- a/tests/Integration/Repositories/MigrationRepositoryTest.php +++ b/tests/Integration/Repositories/MigrationRepositoryTest.php @@ -105,4 +105,13 @@ public function test_repository_is_not_ready_when_table_does_not_exist(): void $this->assertFalse($this->migrationRepository->isReady()); } + + public function test_repository_can_delete_all_records(): void + { + $this->assertCount(2, $this->migrationRepository->getAll()); + + $this->migrationRepository->deleteAll(); + + $this->assertCount(0, $this->migrationRepository->getAll()); + } }