@@ -154,6 +154,28 @@ public function testCheckFileListOrderOutOfOrder():void {
154154 $ migrator ->checkFileListOrder ($ outOfOrder );
155155 }
156156
157+ public function testCheckFileListOrderIgnoresNonNumericFilesAndThrowsOnResultingGap ():void {
158+ $ path = $ this ->getMigrationDirectory ();
159+ $ files = [
160+ "001-first.sql " ,
161+ "a002-second.sql " ,
162+ "003-third.sql " ,
163+ ];
164+ $ this ->createFiles ($ files , $ path );
165+
166+ $ settings = $ this ->createSettings ($ path );
167+ $ migrator = new Migrator ($ settings , $ path );
168+ $ actualFileList = $ migrator ->getMigrationFileList ();
169+
170+ self ::assertSame ([
171+ $ path . DIRECTORY_SEPARATOR . "001-first.sql " ,
172+ $ path . DIRECTORY_SEPARATOR . "003-third.sql " ,
173+ ], $ actualFileList );
174+
175+ $ this ->expectException (MigrationSequenceOrderException::class);
176+ $ migrator ->checkFileListOrder ($ actualFileList );
177+ }
178+
157179 /** @dataProvider dataMigrationFileList */
158180 public function testCheckIntegrityGood (array $ fileList ) {
159181 $ path = $ this ->getMigrationDirectory ();
@@ -531,6 +553,30 @@ public function testNonSqlExtensions(array $fileList) {
531553 self ::assertNull ($ exception );
532554 }
533555
556+ public function testPerformMigrationIgnoresNonNumericPrefixedSqlFiles ():void {
557+ $ path = $ this ->getMigrationDirectory ();
558+ file_put_contents ($ path . DIRECTORY_SEPARATOR . "0001-create-test.sql " , self ::MIGRATION_CREATE );
559+ file_put_contents (
560+ $ path . DIRECTORY_SEPARATOR . "a0002-ignored.sql " ,
561+ "alter table `test` add `ignored_column` varchar(32) "
562+ );
563+
564+ $ settings = $ this ->createSettings ($ path );
565+ $ migrator = new Migrator ($ settings , $ path );
566+ $ migrator ->createMigrationTable ();
567+
568+ $ actualFileList = $ migrator ->getMigrationFileList ();
569+ self ::assertSame ([
570+ $ path . DIRECTORY_SEPARATOR . "0001-create-test.sql " ,
571+ ], $ actualFileList );
572+
573+ $ migrator ->performMigration ($ actualFileList );
574+
575+ $ db = new Database ($ settings );
576+ $ result = $ db ->executeSql ("PRAGMA table_info(test); " );
577+ self ::assertCount (2 , $ result ->fetchAll ());
578+ }
579+
534580 /** @dataProvider dataMigrationFileList */
535581 public function testMigrationThrowsExceptionWhenNoMigrationTable (array $ fileList ) {
536582 $ path = $ this ->getMigrationDirectory ();
0 commit comments