Skip to content

Console commands have been renamed #110

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 21, 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
4 changes: 2 additions & 2 deletions docs/helpers/execution-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ return new class () extends Action
};
```

Call the `php artisan migrate:actions` command.
Call the `php artisan actions` command.

The log file will contain two `success` entries.

Expand Down Expand Up @@ -66,6 +66,6 @@ return new class extends Action
};
```

Call the `php artisan migrate:actions` command.
Call the `php artisan actions` command.

The log file will contain two `failed` entries.
28 changes: 14 additions & 14 deletions docs/how-to-use/creating.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Creating Actions

To create an action use the `make:migration:action` artisan command:
To create an action use the `make:action` artisan command:

```bash
php artisan make:migration:action some_name
php artisan make:action some_name
```

The new action's file will be placed in your `actions` directory in the base path of your app.
Expand All @@ -18,7 +18,7 @@ If you do not specify the "name" attribute, then the file name will be generated
> git branch name ?: 'auto'

```bash
php artisan make:migration:action
php artisan make:action

### When the git repository is found (`base_path('.git')` directory is exists) and HEAD branch name is 'qwerty'
# 2022_10_11_225116_qwerty.php
Expand All @@ -36,31 +36,31 @@ php artisan make:migration:action
You can use nested paths to create actions:

```bash
php artisan make:migration:action Foo/Bar/QweRty
php artisan make:migration:action Foo/Bar/QweRty.php
php artisan make:action Foo/Bar/QweRty
php artisan make:action Foo/Bar/QweRty.php

php artisan make:migration:action Foo\Bar\QweRty
php artisan make:migration:action Foo\Bar\QweRty.php
php artisan make:action Foo\Bar\QweRty
php artisan make:action Foo\Bar\QweRty.php

php artisan make:migration:action foo\bar\QweRty
php artisan make:migration:action foo\bar\QweRty.php
php artisan make:action foo\bar\QweRty
php artisan make:action foo\bar\QweRty.php
```

All of these commands will create a file called `actions/foo/bar/Y_m_d_His_qwe_rty.php`.

For example:

```bash
php artisan make:migration:action foo\bar\QweRty
php artisan make:action foo\bar\QweRty
# actions/foo/bar/2022_10_11_225734_qwe_rty.php

php artisan make:migration:action foo\bar\QweRty.php
php artisan make:action foo\bar\QweRty.php
# actions/foo/bar/2022_10_11_225734_qwe_rty.php

php artisan make:migration:action foo/bar/QweRty
php artisan make:action foo/bar/QweRty
# actions/foo/bar/2022_10_11_225734_qwe_rty.php

php artisan make:migration:action foo/bar/QweRty.php
php artisan make:action foo/bar/QweRty.php
# actions/foo/bar/2022_10_11_225734_qwe_rty.php
```

Expand Down Expand Up @@ -90,7 +90,7 @@ use DragonCode\LaravelActions\Action;

return new class () extends Action
{
public function __invoke(): void {} // called when `php artisan migrate:actions` running
public function __invoke(): void {} // called when `php artisan actions` running

public function down(): void {} // doesn't call when `php artisan migrate:rollback` running
// and any other commands to revert the action.
Expand Down
24 changes: 12 additions & 12 deletions docs/how-to-use/rollback.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
To roll back the latest action operation, you may use the `rollback` command. This command rolls back the last "batch" of actions, which may include multiple action files:

```
php artisan migrate:actions:rollback
php artisan actions:rollback
```

You may roll back a limited number of actions by providing the `step` option to the rollback command. For example, the following command will roll back the last five actions:

```
php artisan migrate:actions:rollback --step=5
php artisan actions:rollback --step=5
```

The `migrate:actions:reset` command will roll back all of your application's actions:
The `actions:reset` command will roll back all of your application's actions:

```
php artisan migrate:actions:reset
php artisan actions:reset
```

For example:

```bash
php artisan migrate:actions:rollback
php artisan actions:rollback
# action batch
# 2022_10_12_021837_some 1
# 2022_10_12_021838_some 2
# 2022_10_12_021839_some 2
# 2022_10_12_021840_some 3 // will be canceled
# 2022_10_12_021841_some 3 // will be canceled

php artisan migrate:actions:rollback --step=1
php artisan actions:rollback --step=1
# action batch
# 2022_10_12_021837_some 1
# 2022_10_12_021838_some 2
# 2022_10_12_021839_some 2
# 2022_10_12_021840_some 3 // will be canceled
# 2022_10_12_021841_some 3 // will be canceled

php artisan migrate:actions:rollback --step=2
php artisan actions:rollback --step=2
# action batch
# 2022_10_12_021837_some 1
# 2022_10_12_021838_some 2 // will be canceled
Expand All @@ -48,24 +48,24 @@ php artisan migrate:actions:rollback --step=2

## Roll Back & Action Using A Single Command

The `migrate:actions:refresh` command will roll back all of your actions and then execute the `migrate:actions` command. This command effectively re-creates your entire
The `actions:refresh` command will roll back all of your actions and then execute the `actions` command. This command effectively re-creates your entire
database:

```
php artisan migrate:actions:refresh
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:

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

## Drop All Actions & Rerun Actions

The `migrate: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 migrate command:

```
php artisan migrate:actions:fresh
php artisan actions:fresh
```
28 changes: 14 additions & 14 deletions docs/how-to-use/running.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Running Actions

To run all of your outstanding actions, execute the `migrate:actions` artisan command:
To run all of your outstanding actions, execute the `actions` artisan command:

```bash
php artisan migrate:actions
php artisan actions
```

Action call order is checked by filename without path:
Expand All @@ -25,13 +25,13 @@ 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
the database at the same time. To avoid this, you may use the `isolated` option when invoking the `migrate:actions` command.
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
run the `migrate:actions` command while that lock is held will not execute; however, the command will still exit with a successful exit status code:
run the `actions` command while that lock is held will not execute; however, the command will still exit with a successful exit status code:

```bash
php artisan migrate:actions --isolated
php artisan actions --isolated
```

## Split Launch Option
Expand All @@ -41,10 +41,10 @@ Sometimes it becomes necessary to launch actions separately, for example, to not
There is a `before` option for this when calling actions:

```bash
php artisan migrate:actions --before
php artisan actions --before
```

When calling the `migrate:actions` command with the `before` parameter, the script will execute only those actions within which the value of the `before` parameter is `true`.
When calling the `actions` command with the `before` parameter, the script will execute only those actions within which the value of the `before` parameter is `true`.

For backwards compatibility, the `before` parameter is set to `true` by default, but actions will only be executed if the option is explicitly passed.

Expand All @@ -71,31 +71,31 @@ To run, you need to pass the `before` parameter. For example, when using [`deplo
task('deploy', [
// ...
'artisan:migrate',
'artisan:migrate:actions --before', // here
'artisan:actions --before', // here
'deploy:publish',
'php-fpm:reload',
'artisan:queue:restart',
'artisan:migrate:actions', // here
'artisan:actions', // here
]);
```

Thus, when `migrate:actions` is called, all actions whose `before` parameter is `true` will be executed, and after that, the remaining tasks will be executed.
Thus, when `actions` is called, all actions whose `before` parameter is `true` will be executed, and after that, the remaining tasks will be executed.

> Note:
> If you call the `migrate:actions` command without the `before` parameter,
> If you call the `actions` command without the `before` parameter,
> then all tasks will be executed regardless of the value of the `$before`
> attribute inside the action class.

## Forcing Actions To Run In Production

> Some commands cannot be executed in production without confirmation.
> These include all commands except `migrate:actions:status` and `migrate:actions`.
> These include all commands except `actions:status` and `actions`.

Some action operations are destructive, which means they may cause you to lose data. In order to protect you from running these commands against your production database,
you will be prompted for confirmation before the commands are executed. To force the commands to run without a prompt, use the `--force` flag:

```bash
php artisan migrate:actions:install --force
php artisan actions:install --force
```

## Execution Every Time
Expand All @@ -118,7 +118,7 @@ return new class extends Action
};
```

If the value is `$once = false`, the `up` method will be called every time the `migrate:actions` command called.
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.

Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-use/status.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Actions Status

The `migrate:actions:status` command displays the execution status of actions. In it you can see which actions were executed and which were not:
The `actions:status` command displays the execution status of actions. In it you can see which actions were executed and which were not:

```
php artisan migrate:actions:status
php artisan actions:status
```
2 changes: 1 addition & 1 deletion docs/prologue/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
For your convenience, we have created an upgrade console command:

```bash
php artisan migrate:actions:upgrade
php artisan actions:upgrade
```

It will do the following:
Expand Down
4 changes: 2 additions & 2 deletions src/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class Action extends Migration
* Determines the type of launch of the action.
*
* If true, then it will be executed once.
* If false, then the action will run every time the `migrate:actions` command is invoked.
* If false, then the action will run every time the `actions` command is invoked.
*
* @var bool
*/
Expand Down Expand Up @@ -61,7 +61,7 @@ abstract class Action extends Migration
* Determines the type of launch of the action.
*
* If true, then it will be executed once.
* If false, then the action will run every time the `migrate:actions` command is invoked.
* If false, then the action will run every time the `actions` command is invoked.
*
* @return bool
*/
Expand Down
18 changes: 9 additions & 9 deletions src/Constants/Names.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

class Names
{
public const FRESH = 'migrate:actions:fresh';
public const FRESH = 'actions:fresh';

public const INSTALL = 'migrate:actions:install';
public const INSTALL = 'actions:install';

public const MAKE = 'make:migration:action';
public const MAKE = 'make:action';

public const MIGRATE = 'migrate:actions';
public const MIGRATE = 'actions';

public const REFRESH = 'migrate:actions:refresh';
public const REFRESH = 'actions:refresh';

public const RESET = 'migrate:actions:reset';
public const RESET = 'actions:reset';

public const ROLLBACK = 'migrate:actions:rollback.md';
public const ROLLBACK = 'actions:rollback';

public const STATUS = 'migrate:actions:status';
public const STATUS = 'actions:status';

public const UPGRADE = 'migrate:actions:upgrade';
public const UPGRADE = 'actions:upgrade';
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Tests\TestCase;
use Throwable;

class MigrateTest extends TestCase
class ActionsTest extends TestCase
{
public function testMigrationCommand()
{
Expand Down