Skip to content

Commit 665c825

Browse files
authored
feat(database): run migrate:fresh without validation by default (#1390)
1 parent 4786a12 commit 665c825

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/Tempest/Framework/Commands/MigrateFreshCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(
3333
)]
3434
public function __invoke(
3535
#[ConsoleArgument(description: 'Validates the integrity of existing migration files by checking if they have been tampered with.')]
36-
bool $validate = true,
36+
bool $validate = false,
3737
#[ConsoleArgument(description: 'Use a specific database.')]
3838
?string $database = null,
3939
#[ConsoleArgument(description: 'Run database seeders after the database has been migrated')]

tests/Integration/Framework/Commands/MigrateFreshCommandTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public function test_migrate_fresh_command(): void
2626

2727
$this->console
2828
->call(MigrateFreshCommand::class)
29-
->assertContains('DROPPING')
30-
->assertNotSee('There is no migration to drop')
29+
->assertContains('MIGRATED')
3130
->assertSuccess();
3231

3332
Assert::assertNotEmpty(Migration::all());
@@ -46,7 +45,6 @@ public function test_migrate_fresh_command_fails_with_validate_when_migrations_a
4645
{
4746
$this->console
4847
->call(MigrateFreshCommand::class)
49-
->assertContains('Migration files are valid')
5048
->assertExitCode(ExitCode::SUCCESS);
5149

5250
$migrations = Migration::all();
@@ -56,25 +54,29 @@ public function test_migrate_fresh_command_fails_with_validate_when_migrations_a
5654
}
5755

5856
$this->console
59-
->call(MigrateFreshCommand::class)
57+
->call(MigrateFreshCommand::class, ['--validate'])
6058
->assertExitCode(ExitCode::INVALID);
6159
}
6260

63-
public function test_migrate_fresh_command_skips_validation_and_runs_if_specified(): void
61+
public function test_migrate_fresh_command_skips_validation_by_default(): void
6462
{
6563
$this->console
6664
->call(MigrateFreshCommand::class)
67-
->assertContains('Migration files are valid')
6865
->assertExitCode(ExitCode::SUCCESS);
6966

7067
$migrations = Migration::all();
68+
7169
foreach ($migrations as $migration) {
7270
$migration->hash = 'invalid-hash';
7371
$migration->save();
7472
}
7573

7674
$this->console
77-
->call('migrate:fresh --no-validate')
75+
->call('migrate:fresh --validate')
76+
->assertExitCode(ExitCode::INVALID);
77+
78+
$this->console
79+
->call('migrate:fresh')
7880
->assertExitCode(ExitCode::SUCCESS);
7981
}
8082
}

0 commit comments

Comments
 (0)