Skip to content

Removed mention of old migration mechanics #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ body:
value: |
- PHP Version:
- Database Driver & Version:
- Migration Actions Version:
- Actions Version:
- Laravel Version:
validations:
required: true
Expand Down
6 changes: 3 additions & 3 deletions docs/how-to-use/rollback.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ database:
php artisan actions:refresh
```

You may roll back & re-migrate a limited number of actions by providing the `step` option to the `refresh` command. For example, the following command will roll back &
re-migrate the last five actions:
You may roll back & re-run a limited number of actions by providing the `step` option to the `refresh` command. For example, the following command will roll back &
re-run the last five actions:

```
php artisan actions:refresh --step=5
```

## Drop All Actions & Rerun Actions

The `actions:fresh` command will drop all actions records from the actions table and then execute the migrate command:
The `actions:fresh` command will drop all actions records from the actions table and then execute the actions command:

```
php artisan actions:fresh
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-use/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bar/2022_10_14_000003_test3 # 3

## Isolating Action Execution

If you are deploying your application across multiple servers and running actions as part of your deployment process, you likely do not want two servers attempting to migrate
If you are deploying your application across multiple servers and running actions as part of your deployment process, you likely do not want two servers attempting to run
the database at the same time. To avoid this, you may use the `isolated` option when invoking the `actions` command.

When the `isolated` option is provided, Laravel will acquire an atomic lock using your application's cache driver before attempting to run your actions. All other attempts to
Expand Down Expand Up @@ -120,7 +120,7 @@ return new class extends Action

If the value is `$once = false`, the `up` method will be called every time the `actions` command called.

In this case, information about it will not be written to the `migration_actions` table and, therefore, the `down` method will not be called when the rollback command is called.
In this case, information about it will not be written to the `actions` table and, therefore, the `down` method will not be called when the rollback command is called.

> Note
>
Expand Down
4 changes: 2 additions & 2 deletions ide.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"codeGenerations": [
{
"id": "dragon-code.create-action",
"name": "Create Migration Action",
"inputFilter": "migration",
"name": "Create Action",
"inputFilter": "actions",
"files": [
{
"directory": "/actions",
Expand Down
280 changes: 140 additions & 140 deletions tests/Commands/ActionsTest.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/Commands/FreshTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public function testFreshCommand(): void

$this->assertDatabaseHasTable($this->table);
$this->assertDatabaseCount($this->table, 1);
$this->assertDatabaseMigrationHas($this->table, 'fresh');
$this->assertDatabaseActionHas($this->table, 'fresh');
}
}
2 changes: 1 addition & 1 deletion tests/Commands/RefreshTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public function testRefreshCommand()

$this->assertDatabaseHasTable($this->table);
$this->assertDatabaseCount($this->table, 1);
$this->assertDatabaseMigrationHas($this->table, 'refresh');
$this->assertDatabaseActionHas($this->table, 'refresh');
}
}
4 changes: 2 additions & 2 deletions tests/Commands/ResetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public function testResetCommand()

$this->assertDatabaseHasTable($this->table);
$this->assertDatabaseCount($this->table, 1);
$this->assertDatabaseMigrationHas($this->table, 'reset');
$this->assertDatabaseActionHas($this->table, 'reset');

$this->artisan(Names::RESET)->assertExitCode(0);

$this->assertDatabaseHasTable($this->table);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'reset');
$this->assertDatabaseActionDoesntLike($this->table, 'reset');
}
}
122 changes: 61 additions & 61 deletions tests/Commands/RollbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function testRollbackCommand()
$this->assertDatabaseHasTable($this->table);
$this->assertDatabaseCount($this->table, 2);

$this->assertDatabaseMigrationHas($this->table, 'rollback_one');
$this->assertDatabaseMigrationHas($this->table, 'rollback_two');
$this->assertDatabaseMigrationDoesntLike($this->table, 'rollback_tree');
$this->assertDatabaseActionHas($this->table, 'rollback_one');
$this->assertDatabaseActionHas($this->table, 'rollback_two');
$this->assertDatabaseActionDoesntLike($this->table, 'rollback_tree');

$this->artisan(Names::ROLLBACK)->assertExitCode(0);

Expand All @@ -47,9 +47,9 @@ public function testRollbackCommand()
$this->assertDatabaseHasTable($this->table);
$this->assertDatabaseCount($this->table, 3);

$this->assertDatabaseMigrationHas($this->table, 'rollback_one');
$this->assertDatabaseMigrationHas($this->table, 'rollback_two');
$this->assertDatabaseMigrationHas($this->table, 'rollback_tree');
$this->assertDatabaseActionHas($this->table, 'rollback_one');
$this->assertDatabaseActionHas($this->table, 'rollback_two');
$this->assertDatabaseActionHas($this->table, 'rollback_tree');
}

public function testEnvironment()
Expand All @@ -62,27 +62,27 @@ public function testEnvironment()

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_on_all');
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_on_production');
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_on_testing');
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_on_many_environments');
$this->assertDatabaseActionDoesntLike($this->table, 'run_on_all');
$this->assertDatabaseActionDoesntLike($this->table, 'run_on_production');
$this->assertDatabaseActionDoesntLike($this->table, 'run_on_testing');
$this->assertDatabaseActionDoesntLike($this->table, 'run_on_many_environments');
$this->artisan(Names::ACTIONS)->assertExitCode(0);

$this->assertDatabaseCount($table, 5);
$this->assertDatabaseCount($this->table, 12);
$this->assertDatabaseMigrationHas($this->table, 'run_on_all');
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_on_production');
$this->assertDatabaseMigrationHas($this->table, 'run_on_testing');
$this->assertDatabaseMigrationHas($this->table, 'run_on_many_environments');
$this->assertDatabaseActionHas($this->table, 'run_on_all');
$this->assertDatabaseActionDoesntLike($this->table, 'run_on_production');
$this->assertDatabaseActionHas($this->table, 'run_on_testing');
$this->assertDatabaseActionHas($this->table, 'run_on_many_environments');
$this->artisan(Names::ACTIONS)->assertExitCode(0);

$this->artisan(Names::ROLLBACK)->assertExitCode(0);
$this->assertDatabaseCount($table, 10);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_on_all');
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_on_production');
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_on_testing');
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_on_many_environments');
$this->assertDatabaseActionDoesntLike($this->table, 'run_on_all');
$this->assertDatabaseActionDoesntLike($this->table, 'run_on_production');
$this->assertDatabaseActionDoesntLike($this->table, 'run_on_testing');
$this->assertDatabaseActionDoesntLike($this->table, 'run_on_many_environments');
}

public function testDownSuccess()
Expand All @@ -95,17 +95,17 @@ public function testDownSuccess()

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_success');
$this->assertDatabaseActionDoesntLike($this->table, 'run_success');
$this->artisan(Names::ACTIONS)->assertExitCode(0);

$this->assertDatabaseCount($table, 2);
$this->assertDatabaseCount($this->table, 12);
$this->assertDatabaseMigrationHas($this->table, 'run_success');
$this->assertDatabaseActionHas($this->table, 'run_success');

$this->artisan(Names::ROLLBACK)->assertExitCode(0);
$this->assertDatabaseCount($table, 4);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_success');
$this->assertDatabaseActionDoesntLike($this->table, 'run_success');
}

public function testDownSuccessOnFailed()
Expand All @@ -118,12 +118,12 @@ public function testDownSuccessOnFailed()

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_success_on_failed');
$this->assertDatabaseActionDoesntLike($this->table, 'run_success_on_failed');
$this->artisan(Names::ACTIONS)->assertExitCode(0);

$this->assertDatabaseCount($table, 2);
$this->assertDatabaseCount($this->table, 12);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_success_on_failed');
$this->assertDatabaseActionDoesntLike($this->table, 'run_success_on_failed');

try {
$this->copySuccessFailureMethod();
Expand All @@ -132,7 +132,7 @@ public function testDownSuccessOnFailed()

$this->assertDatabaseCount($table, 2);
$this->assertDatabaseCount($this->table, 13);
$this->assertDatabaseMigrationHas($this->table, 'run_success_on_failed');
$this->assertDatabaseActionHas($this->table, 'run_success_on_failed');

$this->artisan(Names::ROLLBACK)->assertExitCode(1);
}
Expand All @@ -146,7 +146,7 @@ public function testDownSuccessOnFailed()

$this->assertDatabaseCount($table, 2);
$this->assertDatabaseCount($this->table, 13);
$this->assertDatabaseMigrationHas($this->table, 'run_success_on_failed');
$this->assertDatabaseActionHas($this->table, 'run_success_on_failed');
}

public function testDownFailed()
Expand All @@ -159,17 +159,17 @@ public function testDownFailed()

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_failed');
$this->assertDatabaseActionDoesntLike($this->table, 'run_failed');
$this->artisan(Names::ACTIONS)->assertExitCode(0);

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 12);
$this->assertDatabaseMigrationHas($this->table, 'run_failed');
$this->assertDatabaseActionHas($this->table, 'run_failed');

$this->artisan(Names::ROLLBACK)->assertExitCode(0);
$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_failed');
$this->assertDatabaseActionDoesntLike($this->table, 'run_failed');
}

public function testUpFailedOnException()
Expand All @@ -182,12 +182,12 @@ public function testUpFailedOnException()

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_failed_failure');
$this->assertDatabaseActionDoesntLike($this->table, 'run_failed_failure');
$this->artisan(Names::ACTIONS)->assertExitCode(0);

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 12);
$this->assertDatabaseMigrationDoesntLike($this->table, 'run_failed_failure');
$this->assertDatabaseActionDoesntLike($this->table, 'run_failed_failure');

try {
$this->copyFailedMethod();
Expand All @@ -206,7 +206,7 @@ public function testUpFailedOnException()

$this->assertDatabaseCount($table, 1);
$this->assertDatabaseCount($this->table, 13);
$this->assertDatabaseMigrationHas($this->table, 'run_failed_failure');
$this->assertDatabaseActionHas($this->table, 'run_failed_failure');
}

public function testDisabledBefore()
Expand All @@ -219,22 +219,22 @@ public function testDisabledBefore()

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'test_before_enabled');
$this->assertDatabaseMigrationDoesntLike($this->table, 'test_before_disabled');
$this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled');
$this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled');
$this->artisan(Names::ACTIONS)->assertExitCode(0);

$this->assertDatabaseCount($table, 2);
$this->assertDatabaseCount($this->table, 12);
$this->assertDatabaseMigrationHas($this->table, 'test_before_enabled');
$this->assertDatabaseMigrationHas($this->table, 'test_before_disabled');
$this->assertDatabaseActionHas($this->table, 'test_before_enabled');
$this->assertDatabaseActionHas($this->table, 'test_before_disabled');
$this->artisan(Names::ACTIONS)->assertExitCode(0);

$this->artisan(Names::ROLLBACK)->assertExitCode(0);

$this->assertDatabaseCount($table, 4);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'test_before_enabled');
$this->assertDatabaseMigrationDoesntLike($this->table, 'test_before_disabled');
$this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled');
$this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled');
}

public function testEnabledBefore()
Expand All @@ -247,22 +247,22 @@ public function testEnabledBefore()

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'test_before_enabled');
$this->assertDatabaseMigrationDoesntLike($this->table, 'test_before_disabled');
$this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled');
$this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled');
$this->artisan(Names::ACTIONS, ['--before' => true])->assertExitCode(0);

$this->assertDatabaseCount($table, 1);
$this->assertDatabaseCount($this->table, 11);
$this->assertDatabaseMigrationHas($this->table, 'test_before_enabled');
$this->assertDatabaseMigrationDoesntLike($this->table, 'test_before_disabled');
$this->assertDatabaseActionHas($this->table, 'test_before_enabled');
$this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled');
$this->artisan(Names::ACTIONS, ['--before' => true])->assertExitCode(0);

$this->artisan(Names::ROLLBACK)->assertExitCode(0);

$this->assertDatabaseCount($table, 2);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'test_before_enabled');
$this->assertDatabaseMigrationDoesntLike($this->table, 'test_before_disabled');
$this->assertDatabaseActionDoesntLike($this->table, 'test_before_enabled');
$this->assertDatabaseActionDoesntLike($this->table, 'test_before_disabled');
}

public function testDI(): void
Expand All @@ -275,32 +275,32 @@ public function testDI(): void

$this->assertDatabaseCount($table, 0);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'invoke');
$this->assertDatabaseMigrationDoesntLike($this->table, 'invoke_down');
$this->assertDatabaseMigrationDoesntLike($this->table, 'up_down');
$this->assertDatabaseMigrationDoesntLike($table, 'up_down', column: 'value');
$this->assertDatabaseMigrationDoesntLike($table, 'invoke_down', column: 'value');
$this->assertDatabaseMigrationDoesntLike($table, 'invoke', column: 'value');
$this->assertDatabaseActionDoesntLike($this->table, 'invoke');
$this->assertDatabaseActionDoesntLike($this->table, 'invoke_down');
$this->assertDatabaseActionDoesntLike($this->table, 'up_down');
$this->assertDatabaseActionDoesntLike($table, 'up_down', column: 'value');
$this->assertDatabaseActionDoesntLike($table, 'invoke_down', column: 'value');
$this->assertDatabaseActionDoesntLike($table, 'invoke', column: 'value');
$this->artisan(Names::ACTIONS)->assertExitCode(0);

$this->assertDatabaseCount($table, 3);
$this->assertDatabaseCount($this->table, 3);
$this->assertDatabaseMigrationHas($this->table, 'invoke');
$this->assertDatabaseMigrationHas($this->table, 'invoke_down');
$this->assertDatabaseMigrationHas($this->table, 'up_down');
$this->assertDatabaseMigrationHas($table, 'up_down', column: 'value');
$this->assertDatabaseMigrationHas($table, 'invoke_down', column: 'value');
$this->assertDatabaseMigrationHas($table, 'invoke', column: 'value');
$this->assertDatabaseActionHas($this->table, 'invoke');
$this->assertDatabaseActionHas($this->table, 'invoke_down');
$this->assertDatabaseActionHas($this->table, 'up_down');
$this->assertDatabaseActionHas($table, 'up_down', column: 'value');
$this->assertDatabaseActionHas($table, 'invoke_down', column: 'value');
$this->assertDatabaseActionHas($table, 'invoke', column: 'value');

$this->artisan(Names::ROLLBACK)->assertExitCode(0);

$this->assertDatabaseCount($table, 2);
$this->assertDatabaseCount($this->table, 0);
$this->assertDatabaseMigrationDoesntLike($this->table, 'invoke');
$this->assertDatabaseMigrationDoesntLike($this->table, 'invoke_down');
$this->assertDatabaseMigrationDoesntLike($this->table, 'up_down');
$this->assertDatabaseMigrationDoesntLike($table, 'up_down', column: 'value');
$this->assertDatabaseMigrationHas($table, 'invoke_down', column: 'value');
$this->assertDatabaseMigrationHas($table, 'invoke', column: 'value');
$this->assertDatabaseActionDoesntLike($this->table, 'invoke');
$this->assertDatabaseActionDoesntLike($this->table, 'invoke_down');
$this->assertDatabaseActionDoesntLike($this->table, 'up_down');
$this->assertDatabaseActionDoesntLike($table, 'up_down', column: 'value');
$this->assertDatabaseActionHas($table, 'invoke_down', column: 'value');
$this->assertDatabaseActionHas($table, 'invoke', column: 'value');
}
}
2 changes: 1 addition & 1 deletion tests/Commands/StatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public function testStatusCommand()

$this->artisan(Names::STATUS)->assertExitCode(0);

$this->assertDatabaseMigrationHas($this->table, 'status');
$this->assertDatabaseActionHas($this->table, 'status');
}
}
4 changes: 2 additions & 2 deletions tests/Concerns/AssertDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function assertDatabaseDoesntTable(string $table): void
);
}

protected function assertDatabaseMigrationHas(string $table, $value, $connection = null, string $column = 'action'): void
protected function assertDatabaseActionHas(string $table, $value, $connection = null, string $column = 'action'): void
{
$this->assertDatabaseHasLike($table, $column, $value, $connection);
}
Expand All @@ -37,7 +37,7 @@ protected function assertDatabaseHasLike(string $table, string $column, $value,
$this->assertTrue($exists);
}

protected function assertDatabaseMigrationDoesntLike(string $table, $value, $connection = null, string $column = 'action'): void
protected function assertDatabaseActionDoesntLike(string $table, $value, $connection = null, string $column = 'action'): void
{
$this->assertDatabaseDoesntLike($table, $column, $value, $connection);
}
Expand Down
Loading