@@ -128,6 +128,58 @@ public function testDownMethodsDropTables(): void
128128 $ this ->assertFalse (Schema::hasTable ('workflow_run_lineage_entries ' ));
129129 }
130130
131+ /**
132+ * @return list<array{string}>
133+ */
134+ public static function sqliteRollbackCommandProvider (): array
135+ {
136+ return [['migrate:rollback ' ], ['migrate:reset ' ]];
137+ }
138+
139+ /**
140+ * @dataProvider sqliteRollbackCommandProvider
141+ */
142+ public function testSqlitePackageMigrationsSupportRollbackCommands (string $ command ): void
143+ {
144+ $ databasePath = tempnam (sys_get_temp_dir (), 'workflow-sqlite-migrations- ' );
145+
146+ $ this ->assertIsString ($ databasePath );
147+
148+ $ connection = 'workflow_test_sqlite ' ;
149+ config ()
150+ ->set (
151+ "database.connections. {$ connection }" ,
152+ [
153+ 'driver ' => 'sqlite ' ,
154+ 'database ' => $ databasePath ,
155+ 'prefix ' => '' ,
156+ 'foreign_key_constraints ' => true ,
157+ ],
158+ );
159+
160+ try {
161+ $ this ->artisan ('migrate:fresh ' , [
162+ '--database ' => $ connection ,
163+ '--path ' => dirname (__DIR__ , 3 ) . '/src/migrations ' ,
164+ '--realpath ' => true ,
165+ ])->assertExitCode (0 );
166+
167+ $ this ->assertSqliteWorkflowTablesExist ($ connection );
168+
169+ $ this ->artisan ($ command , [
170+ '--database ' => $ connection ,
171+ '--path ' => dirname (__DIR__ , 3 ) . '/src/migrations ' ,
172+ '--realpath ' => true ,
173+ ])->assertExitCode (0 );
174+
175+ $ this ->assertSqliteWorkflowTablesMissing ($ connection );
176+ } finally {
177+ if (is_file ($ databasePath )) {
178+ @unlink ($ databasePath );
179+ }
180+ }
181+ }
182+
131183 public function testTimerProjectionRowsDefaultToCurrentSchemaVersion (): void
132184 {
133185 /** @var WorkflowRunTimerEntry $entry */
@@ -182,4 +234,63 @@ private function stringColumnLength(string $table, string $column): int
182234
183235 $ this ->fail ("Unable to determine {$ table }. {$ column } length for {$ driver }. " );
184236 }
237+
238+ private function assertSqliteWorkflowTablesExist (string $ connection ): void
239+ {
240+ foreach (self ::sqliteWorkflowTables () as $ table ) {
241+ $ this ->assertTrue (
242+ Schema::connection ($ connection )->hasTable ($ table ),
243+ "Expected SQLite table [ {$ table }] to exist. " ,
244+ );
245+ }
246+ }
247+
248+ private function assertSqliteWorkflowTablesMissing (string $ connection ): void
249+ {
250+ foreach (self ::sqliteWorkflowTables () as $ table ) {
251+ $ this ->assertFalse (
252+ Schema::connection ($ connection )->hasTable ($ table ),
253+ "Expected SQLite table [ {$ table }] to be dropped. " ,
254+ );
255+ }
256+ }
257+
258+ /**
259+ * @return list<string>
260+ */
261+ private static function sqliteWorkflowTables (): array
262+ {
263+ return [
264+ 'workflows ' ,
265+ 'workflow_logs ' ,
266+ 'workflow_signals ' ,
267+ 'workflow_timers ' ,
268+ 'workflow_exceptions ' ,
269+ 'workflow_relationships ' ,
270+ 'workflow_instances ' ,
271+ 'workflow_runs ' ,
272+ 'workflow_run_timers ' ,
273+ 'workflow_tasks ' ,
274+ 'activity_executions ' ,
275+ 'workflow_failures ' ,
276+ 'workflow_run_summaries ' ,
277+ 'workflow_history_events ' ,
278+ 'workflow_commands ' ,
279+ 'workflow_links ' ,
280+ 'activity_attempts ' ,
281+ 'workflow_worker_compatibility_heartbeats ' ,
282+ 'workflow_updates ' ,
283+ 'workflow_signal_records ' ,
284+ 'workflow_run_waits ' ,
285+ 'workflow_run_timeline_entries ' ,
286+ 'workflow_run_lineage_entries ' ,
287+ 'workflow_run_timer_entries ' ,
288+ 'workflow_schedules ' ,
289+ 'workflow_messages ' ,
290+ 'workflow_memos ' ,
291+ 'workflow_search_attributes ' ,
292+ 'workflow_child_calls ' ,
293+ 'workflow_schedule_history_events ' ,
294+ ];
295+ }
185296}
0 commit comments