88use Cake \Console \TestSuite \StubConsoleOutput ;
99use Cake \Database \Connection ;
1010use Cake \Datasource \ConnectionManager ;
11+ use Exception ;
1112use InvalidArgumentException ;
1213use Migrations \Db \Adapter \AdapterInterface ;
1314use Migrations \Db \Adapter \PostgresAdapter ;
@@ -1499,16 +1500,15 @@ public function testDropIndexByNameWithSchema(): void
14991500
15001501 public function testAddGistIndex (): void
15011502 {
1502- // GiST indexes on text columns require an operator class.
1503- // We use inet type which has built-in GiST support.
1504- $ table = new Table ('table1 ' , [], $ this ->adapter );
1505- $ table ->addColumn ('ip_range ' , 'inet ' )
1506- ->save ();
1503+ // GiST indexes require specific data types with GiST support.
1504+ // We use int4range which has built-in GiST support in PostgreSQL.
1505+ $ this ->adapter ->execute ('CREATE TABLE table1 (id SERIAL PRIMARY KEY, int_range int4range) ' );
15071506
1508- $ table ->addIndex ('ip_range ' , ['type ' => 'gist ' ])
1507+ $ table = new Table ('table1 ' , [], $ this ->adapter );
1508+ $ table ->addIndex ('int_range ' , ['type ' => 'gist ' ])
15091509 ->save ();
15101510
1511- $ this ->assertTrue ($ table ->hasIndex ('ip_range ' ));
1511+ $ this ->assertTrue ($ table ->hasIndex ('int_range ' ));
15121512
15131513 // Verify the index uses the GIST access method
15141514 $ rows = $ this ->adapter ->fetchAll (
@@ -1517,7 +1517,7 @@ public function testAddGistIndex(): void
15171517 JOIN pg_class c ON c.oid = i.indexrelid
15181518 JOIN pg_am am ON am.oid = c.relam
15191519 JOIN pg_class t ON t.oid = i.indrelid
1520- WHERE t.relname = 'table1' AND c.relname = 'table1_ip_range ' " ,
1520+ WHERE t.relname = 'table1' AND c.relname = 'table1_int_range ' " ,
15211521 );
15221522 $ this ->assertCount (1 , $ rows );
15231523 $ this ->assertEquals ('gist ' , $ rows [0 ]['access_method ' ]);
@@ -1626,7 +1626,7 @@ public function testAddIndexWithOpclass(): void
16261626 // Skip if extension is not available
16271627 try {
16281628 $ this ->adapter ->execute ('CREATE EXTENSION IF NOT EXISTS pg_trgm ' );
1629- } catch (\ Exception $ e ) {
1629+ } catch (Exception ) {
16301630 $ this ->markTestSkipped ('pg_trgm extension is not available ' );
16311631 }
16321632
0 commit comments