1313
1414use Doctrine \DBAL \Connection ;
1515use Doctrine \DBAL \Exception \TableNotFoundException ;
16+ use Doctrine \DBAL \Schema \Table ;
17+ use Doctrine \DBAL \Types \Types ;
1618use Doctrine \ORM \Tools \Event \GenerateSchemaEventArgs ;
1719
1820abstract class AbstractSchemaListener
@@ -22,8 +24,16 @@ abstract public function postGenerateSchema(GenerateSchemaEventArgs $event): voi
2224 protected function getIsSameDatabaseChecker (Connection $ connection ): \Closure
2325 {
2426 return static function (\Closure $ exec ) use ($ connection ): bool {
27+ $ schemaManager = $ connection ->createSchemaManager ();
28+
2529 $ checkTable = 'schema_subscriber_check_ ' .bin2hex (random_bytes (7 ));
26- $ connection ->executeStatement (sprintf ('CREATE TABLE %s (id INTEGER NOT NULL) ' , $ checkTable ));
30+ $ table = new Table ($ checkTable );
31+ $ table ->addColumn ('id ' , Types::INTEGER )
32+ ->setAutoincrement (true )
33+ ->setNotnull (true );
34+ $ table ->setPrimaryKey (['id ' ]);
35+
36+ $ schemaManager ->createTable ($ table );
2737
2838 try {
2939 $ exec (sprintf ('DROP TABLE %s ' , $ checkTable ));
@@ -32,7 +42,7 @@ protected function getIsSameDatabaseChecker(Connection $connection): \Closure
3242 }
3343
3444 try {
35- $ connection -> executeStatement ( sprintf ( ' DROP TABLE %s ' , $ checkTable) );
45+ $ schemaManager -> dropTable ( $ checkTable );
3646
3747 return false ;
3848 } catch (TableNotFoundException ) {
0 commit comments