@@ -109,9 +109,44 @@ public function testProviderLoadsPackageMigrationsForFreshApps(): void
109109 $ this ->assertTrue (Schema::hasTable ('workflow_instances ' ));
110110 $ this ->assertTrue (Schema::hasTable ('workflow_runs ' ));
111111 $ this ->assertTrue (Schema::hasTable ('workflow_run_summaries ' ));
112+ $ this ->assertTrue (Schema::hasColumn ('workflow_run_summaries ' , 'memo ' ));
112113 $ this ->assertTrue (Schema::hasTable ('workflow_commands ' ));
113114 }
114115
116+ public function testPublishedMigrationsCanRunAsInstallSource (): void
117+ {
118+ $ this ->deletePublishedWorkflowMigrations ();
119+
120+ try {
121+ Artisan::call ('vendor:publish ' , [
122+ '--tag ' => 'migrations ' ,
123+ '--force ' => true ,
124+ ]);
125+
126+ $ migrationFiles = glob (database_path ('migrations/*.php ' )) ?: [];
127+ $ this ->assertNotEmpty ($ migrationFiles , 'Migrations should be published ' );
128+
129+ Schema::dropAllTables ();
130+
131+ $ this ->artisan ('migrate:install ' )
132+ ->run ();
133+
134+ $ this ->artisan ('migrate ' , [
135+ '--path ' => database_path ('migrations ' ),
136+ '--realpath ' => true ,
137+ ])->run ();
138+
139+ $ this ->assertTrue (Schema::hasTable ('workflow_instances ' ));
140+ $ this ->assertTrue (Schema::hasTable ('workflow_runs ' ));
141+ $ this ->assertTrue (Schema::hasTable ('workflow_run_summaries ' ));
142+ $ this ->assertTrue (Schema::hasColumn ('workflow_run_summaries ' , 'memo ' ));
143+ $ this ->assertTrue (Schema::hasTable ('workflow_schedules ' ));
144+ $ this ->assertTrue (Schema::hasTable ('workflow_schedule_history_events ' ));
145+ } finally {
146+ $ this ->deletePublishedWorkflowMigrations ();
147+ }
148+ }
149+
115150 public function testCommandsAreRegistered (): void
116151 {
117152 $ registeredCommands = array_keys (Artisan::all ());
@@ -218,8 +253,17 @@ public function testLoopingEventSkipsWatchdogsBeforeWorkflowTablesExist(): void
218253 Cache::forget ('workflow:watchdog:looping ' );
219254 Cache::forget (TaskWatchdog::LOOP_THROTTLE_KEY );
220255
221- Schema::dropIfExists ('workflows ' );
222- Schema::dropIfExists ('workflow_worker_compatibility_heartbeats ' );
256+ foreach ([
257+ 'workflow_relationships ' ,
258+ 'workflow_exceptions ' ,
259+ 'workflow_timers ' ,
260+ 'workflow_signals ' ,
261+ 'workflow_logs ' ,
262+ 'workflows ' ,
263+ 'workflow_worker_compatibility_heartbeats ' ,
264+ ] as $ table ) {
265+ Schema::dropIfExists ($ table );
266+ }
223267
224268 Event::dispatch (new Looping ('redis ' , 'default ' ));
225269
@@ -291,4 +335,16 @@ public function testLoopingEventRepairsOverdueV2Task(): void
291335 $ this ->assertSame (1 , $ task ->repair_count );
292336 $ this ->assertNotNull ($ task ->last_dispatched_at );
293337 }
338+
339+ private function deletePublishedWorkflowMigrations (): void
340+ {
341+ $ sourceFiles = glob (dirname (__DIR__ , 3 ) . '/src/migrations/*.php ' ) ?: [];
342+ $ publishedNames = array_fill_keys (array_map ('basename ' , $ sourceFiles ), true );
343+
344+ foreach (glob (database_path ('migrations/*.php ' )) ?: [] as $ file ) {
345+ if (isset ($ publishedNames [basename ($ file )])) {
346+ @unlink ($ file );
347+ }
348+ }
349+ }
294350}
0 commit comments