You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Actions are like version control for your migration process, allowing your team to modify and share the application's actionable schema. If you have ever had to tell a teammate to manually perform any action on a producton server, you've come across an issue that actions solves.
11
+
> Actions are like version control for your migration process, allowing your team to modify and share the application's actionable schema. If you have ever had to tell a teammate
12
+
> to manually perform any action on a producton server, you've come across an issue that actions solves.
12
13
13
14
## Installation
14
15
@@ -23,7 +24,7 @@ Or manually update `require` block of `composer.json` and run `composer update`.
23
24
```json
24
25
{
25
26
"require": {
26
-
"dragon-code/laravel-migration-actions": "^2.6"
27
+
"dragon-code/laravel-migration-actions": "^2.9"
27
28
}
28
29
}
29
30
```
@@ -253,6 +254,57 @@ return new class extends Actionable
253
254
254
255
By default, no actions will be excluded. The same happens if you specify `null` or `[]` value.
255
256
257
+
#### Split Launch Option
258
+
259
+
Sometimes it becomes necessary to launch actions separately, for example, to notify about the successful deployment of a project.
260
+
261
+
There is a `before` option for this when calling actions:
262
+
263
+
```bash
264
+
php artisan migrate:actions --before
265
+
```
266
+
267
+
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`.
268
+
269
+
For backwards compatibility, the `before` parameter is set to `true` by default, but actions will only be executed if the option is explicitly passed.
270
+
271
+
```php
272
+
use DragonCode\LaravelActions\Support\Actionable;
273
+
274
+
return new class extends Actionable
275
+
{
276
+
protected $before = false;
277
+
278
+
public function up(): void
279
+
{
280
+
// your code
281
+
}
282
+
};
283
+
```
284
+
285
+
For example, you need to call actions when deploying an application. Some actions should be run after the migrations are deployed, and others after the application is fully
286
+
launched.
287
+
288
+
To run, you need to pass the `before` parameter. For example, when using [`deployer`](https://github.com/deployphp/deployer) it would look like this:
289
+
290
+
```php
291
+
task('deploy', [
292
+
// ...
293
+
'artisan:migrate',
294
+
'artisan:migrate:actions --before', // here
295
+
'deploy:publish',
296
+
'php-fpm:reload',
297
+
'artisan:queue:restart',
298
+
'artisan:migrate:actions', // here
299
+
]);
300
+
```
301
+
302
+
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.
303
+
304
+
> Note:
305
+
> If you call the `migrate:actions` command without the `before` parameter, then all tasks will be executed regardless of the value of the `$before` attribute inside the action
306
+
> class.
307
+
256
308
#### Database Transactions
257
309
258
310
In some cases, it becomes necessary to undo previously performed actions in the database. For example, when code execution throws an error. To do this, the code must be wrapped in
0 commit comments