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 26
26
27
27
'table ' => 'operations ' ,
28
28
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
+
29
48
/*
30
49
|--------------------------------------------------------------------------
31
50
| Operations Path
Original file line number Diff line number Diff line change @@ -215,14 +215,20 @@ use DragonCode\LaravelDeployOperations\Operation;
215
215
216
216
return new class extends Operation
217
217
{
218
- protected bool $transactions = true;
219
-
220
- protected int $transactionAttempts = 3;
221
-
222
218
public function __invoke(): void
223
219
{
224
220
// some code
225
221
}
222
+
223
+ public function enabledTransactions(): bool
224
+ {
225
+ return true;
226
+ }
227
+
228
+ public function transactionAttempts(): int
229
+ {
230
+ return 4;
231
+ }
226
232
};
227
233
```
228
234
Original file line number Diff line number Diff line change 11
11
12
12
## Minor-Impact Changes
13
13
14
- - [ Changed file location] ( #changed-file-location )
14
+ - [ Changed directory location] ( #changed-directory-location )
15
+ - [ Removed database transaction properties] ( #removed-database-transaction-properties )
15
16
16
17
## Low-Impact Changes
17
18
@@ -136,10 +137,21 @@ class Names
136
137
}
137
138
```
138
139
139
- ## Changed file location
140
+ ## Changed directory location
140
141
141
142
File storage directory changed to ` operations ` from ` actions ` .
142
143
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
+
143
155
## Stub name changed
144
156
145
157
If 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
17
17
*/
18
18
protected bool $ once = true ;
19
19
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
-
30
20
/**
31
21
* Determines which environment to run on.
32
22
*/
@@ -64,15 +54,15 @@ public function isOnce(): bool
64
54
*/
65
55
public function enabledTransactions (): bool
66
56
{
67
- return $ this -> transactions ;
57
+ return ( bool ) config ( ' deploy-operations. transactions.enabled ' ) ;
68
58
}
69
59
70
60
/**
71
61
* The number of attempts to execute a request within a transaction before throwing an error.
72
62
*/
73
63
public function transactionAttempts (): int
74
64
{
75
- return $ this -> transactionAttempts ;
65
+ return config ( ' deploy-operations.transactions.attempts ' , 1 ) ;
76
66
}
77
67
78
68
/**
Original file line number Diff line number Diff line change @@ -5,8 +5,6 @@ use Illuminate\Support\Facades\DB;
5
5
use Ramsey\Uuid\Uuid;
6
6
7
7
return new class extends Operation {
8
- protected bool $transactions = true;
9
-
10
8
public function up(): void
11
9
{
12
10
$this->table()->insert([
@@ -16,6 +14,11 @@ return new class extends Operation {
16
14
]);
17
15
}
18
16
17
+ public function enabledTransactions(): bool
18
+ {
19
+ return true;
20
+ }
21
+
19
22
protected function table()
20
23
{
21
24
return DB::table('transactions');
Original file line number Diff line number Diff line change @@ -5,8 +5,6 @@ use Illuminate\Support\Facades\DB;
5
5
use Ramsey\Uuid\Uuid;
6
6
7
7
return new class extends Operation {
8
- protected bool $transactions = true;
9
-
10
8
public function up(): void
11
9
{
12
10
$this->table()->insert([
@@ -18,6 +16,11 @@ return new class extends Operation {
18
16
throw new Exception('Random message');
19
17
}
20
18
19
+ public function enabledTransactions(): bool
20
+ {
21
+ return true;
22
+ }
23
+
21
24
protected function table()
22
25
{
23
26
return DB::table('transactions');
You can’t perform that action at this time.
0 commit comments