File tree Expand file tree Collapse file tree 3 files changed +26
-11
lines changed Expand file tree Collapse file tree 3 files changed +26
-11
lines changed Original file line number Diff line number Diff line change 80
80
| After Dump
81
81
|--------------------------------------------------------------------------
82
82
|
83
- | Run this closure after dumping snapshot. Helps when output may vary by
84
- | environment in unimportant ways which would just pollute the SCM history
85
- | with noisy changes.
83
+ | Run this Artisan command or closure after dumping snapshot. Helps when
84
+ | output may vary by environment in unimportant ways which would just
85
+ | pollute the SCM history with noisy changes.
86
86
|
87
- | Must accept two arguments: `function ($schema_sql_path, $data_sql_path)`.
87
+ | If an array values must align with arguments to `Artisan::call()`.
88
+ | If a closure it must be: `function ($schema_sql_path, $data_sql_path)`.
88
89
|
89
90
*/
90
91
'after-dump ' => null ,
94
95
| After Load
95
96
|--------------------------------------------------------------------------
96
97
|
97
- | Run this closure after loading snapshot. Helps when one needs to refresh
98
- | materialized views or otherwise prep a fresh DB.
98
+ | Run this Artisan command or closure after loading snapshot. Helps when
99
+ | one needs to refresh materialized views or otherwise prep a fresh DB.
99
100
|
100
- | Must accept two arguments: `function ($schema_sql_path, $data_sql_path)`.
101
+ | If an array values must align with arguments to `Artisan::call()`.
102
+ | If a closure it must be: `function ($schema_sql_path, $data_sql_path)`.
101
103
|
102
104
*/
103
105
'after-load ' => null ,
Original file line number Diff line number Diff line change 3
3
namespace AlwaysOpen \MigrationSnapshot \Commands ;
4
4
5
5
use Illuminate \Console \Command ;
6
+ use Illuminate \Support \Facades \Artisan ;
6
7
use Illuminate \Support \Facades \DB ;
7
8
8
9
final class MigrateDumpCommand extends Command
@@ -84,9 +85,14 @@ public function handle()
84
85
$ this ->info ('Dumped Data ' );
85
86
}
86
87
87
- $ after_dump = config ('migration-snapshot.after-dump ' );
88
- if ($ after_dump ) {
89
- $ after_dump ($ schema_sql_path , $ data_path );
88
+ if ($ after_dump = config ('migration-snapshot.after-dump ' )) {
89
+ if (is_string ($ after_dump )) {
90
+ Artisan::call ($ after_dump );
91
+ } elseif (is_array ($ after_dump )) {
92
+ Artisan::call ($ after_dump [0 ], $ after_dump [1 ] ?? [], $ after_dump [2 ] ?? null );
93
+ } else {
94
+ $ after_dump ($ schema_sql_path , $ data_path );
95
+ }
90
96
$ this ->info ('Ran After-dump ' );
91
97
}
92
98
}
Original file line number Diff line number Diff line change 3
3
namespace AlwaysOpen \MigrationSnapshot \Commands ;
4
4
5
5
use Illuminate \Console \Command ;
6
+ use Illuminate \Support \Facades \Artisan ;
6
7
use Illuminate \Support \Facades \DB ;
7
8
use Illuminate \Support \Str ;
8
9
use InvalidArgumentException ;
@@ -89,7 +90,13 @@ public function handle()
89
90
}
90
91
91
92
if ($ after_load = config ('migration-snapshot.after-load ' )) {
92
- $ after_load ($ schema_sql_path , $ data_path );
93
+ if (is_string ($ after_load )) {
94
+ Artisan::call ($ after_load );
95
+ } elseif (is_array ($ after_load )) {
96
+ Artisan::call ($ after_load [0 ], $ after_load [1 ] ?? [], $ after_load [2 ] ?? null );
97
+ } else {
98
+ $ after_load ($ schema_sql_path , $ data_path );
99
+ }
93
100
$ this ->info ('Ran After-load ' );
94
101
}
95
102
}
You can’t perform that action at this time.
0 commit comments