File tree Expand file tree Collapse file tree 6 files changed +55
-22
lines changed Expand file tree Collapse file tree 6 files changed +55
-22
lines changed Original file line number Diff line number Diff line change 2626
2727 'table ' => 'operations ' ,
2828
29+ /*
30+ |--------------------------------------------------------------------------
31+ | Database Transations
32+ |--------------------------------------------------------------------------
33+ |
34+ | This setting defines the rules for working with database transactions.
35+ | This specifies a common value for all operations, but you can override this
36+ | value directly in the class of the operation itself.
37+ */
38+
39+ 'transactions ' => [
40+ // | Determines whether the use of database transactions is enabled.
41+
42+ 'enabled ' => false ,
43+
44+ // | The number of attempts to execute a request within a transaction before throwing an error.
45+ 'attempts ' => 1 ,
46+ ],
47+
2948 /*
3049 |--------------------------------------------------------------------------
3150 | Operations Path
Original file line number Diff line number Diff line change @@ -215,14 +215,20 @@ use DragonCode\LaravelDeployOperations\Operation;
215215
216216return new class extends Operation
217217{
218- protected bool $transactions = true;
219-
220- protected int $transactionAttempts = 3;
221-
222218 public function __invoke(): void
223219 {
224220 // some code
225221 }
222+
223+ public function enabledTransactions(): bool
224+ {
225+ return true;
226+ }
227+
228+ public function transactionAttempts(): int
229+ {
230+ return 4;
231+ }
226232};
227233```
228234
Original file line number Diff line number Diff line change 1111
1212## Minor-Impact Changes
1313
14- - [ Changed file location] ( #changed-file-location )
14+ - [ Changed directory location] ( #changed-directory-location )
15+ - [ Removed database transaction properties] ( #removed-database-transaction-properties )
1516
1617## Low-Impact Changes
1718
@@ -136,10 +137,21 @@ class Names
136137}
137138```
138139
139- ## Changed file location
140+ ## Changed directory location
140141
141142File storage directory changed to ` operations ` from ` actions ` .
142143
144+ ## Removed database transaction properties
145+
146+ The following properties have been removed:
147+
148+ - ` $transactions `
149+ - ` $transactionAttempts `
150+
151+ Instead, you can use the previously available ` enabledTransactions ` and ` transactionAttempts ` methods.
152+
153+ The default setting for these parameters has been moved to the ` transactions ` section of the configuration file.
154+
143155## Stub name changed
144156
145157If you published a stub file, then you also need to rename it from ` stubs/action.stub ` to ` stubs/deploy-operation.stub `
Original file line number Diff line number Diff line change @@ -17,16 +17,6 @@ abstract class Operation
1717 */
1818 protected bool $ once = true ;
1919
20- /**
21- * Determines a call to database transactions.
22- *
23- * By default, false.
24- */
25- protected bool $ transactions = false ;
26-
27- /** The number of attempts to execute a request within a transaction before throwing an error. */
28- protected int $ transactionAttempts = 1 ;
29-
3020 /**
3121 * Determines which environment to run on.
3222 */
@@ -64,15 +54,15 @@ public function isOnce(): bool
6454 */
6555 public function enabledTransactions (): bool
6656 {
67- return $ this -> transactions ;
57+ return ( bool ) config ( ' deploy-operations. transactions.enabled ' ) ;
6858 }
6959
7060 /**
7161 * The number of attempts to execute a request within a transaction before throwing an error.
7262 */
7363 public function transactionAttempts (): int
7464 {
75- return $ this -> transactionAttempts ;
65+ return config ( ' deploy-operations.transactions.attempts ' , 1 ) ;
7666 }
7767
7868 /**
Original file line number Diff line number Diff line change @@ -5,8 +5,6 @@ use Illuminate\Support\Facades\DB;
55use Ramsey\Uuid\Uuid;
66
77return new class extends Operation {
8- protected bool $transactions = true;
9-
108 public function up(): void
119 {
1210 $this->table()->insert([
@@ -16,6 +14,11 @@ return new class extends Operation {
1614 ]);
1715 }
1816
17+ public function enabledTransactions(): bool
18+ {
19+ return true;
20+ }
21+
1922 protected function table()
2023 {
2124 return DB::table('transactions');
Original file line number Diff line number Diff line change @@ -5,8 +5,6 @@ use Illuminate\Support\Facades\DB;
55use Ramsey\Uuid\Uuid;
66
77return new class extends Operation {
8- protected bool $transactions = true;
9-
108 public function up(): void
119 {
1210 $this->table()->insert([
@@ -18,6 +16,11 @@ return new class extends Operation {
1816 throw new Exception('Random message');
1917 }
2018
19+ public function enabledTransactions(): bool
20+ {
21+ return true;
22+ }
23+
2124 protected function table()
2225 {
2326 return DB::table('transactions');
You can’t perform that action at this time.
0 commit comments