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
Copy file name to clipboardExpand all lines: README.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@
26
26
*[Generating actions](#generating-actions)
27
27
*[Running Actions](#running-actions)
28
28
*[Forcing Actions To Run In Production](#forcing-actions-to-run-in-production)
29
+
*[Execution every time](#execution-every-time)
29
30
*[Rolling Back Actions](#rolling-back-actions)
30
31
*[Roll Back & Action Using A Single Command](#roll-back--action-using-a-single-command)
31
32
*[Actions Status](#actions-status)
@@ -109,6 +110,44 @@ database, you will be prompted for confirmation before the commands are executed
109
110
php artisan migrate:actions --force
110
111
```
111
112
113
+
#### Execution every time
114
+
115
+
In some cases, you need to call the code every time you deploy the application. For example, to call reindexing.
116
+
117
+
To do this, override the `$once` variable in the action file:
118
+
119
+
```php
120
+
use Helldar\LaravelActions\Support\Actionable;
121
+
122
+
class Reindex extends Actionable
123
+
{
124
+
/**
125
+
* Determines the type of launch of the action.
126
+
*
127
+
* If true, then it will be executed once.
128
+
* If false, then the action will run every time the `migrate:actions` command is invoked.
129
+
*
130
+
* @var bool
131
+
*/
132
+
protected $once = false;
133
+
134
+
public function up(): void
135
+
{
136
+
// your calling code
137
+
}
138
+
139
+
public function down(): void
140
+
{
141
+
//
142
+
}
143
+
}
144
+
```
145
+
146
+
If the value is `$once = false`, the `up` method will be called every time the `migrate:actions` command called.
147
+
148
+
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
149
+
command is called.
150
+
112
151
### Rolling Back Actions
113
152
114
153
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
0 commit comments