88use CodeRhapsodie \DataflowBundle \Repository \JobRepository ;
99use CodeRhapsodie \DataflowBundle \Repository \ScheduledDataflowRepository ;
1010use CodeRhapsodie \DataflowBundle \SchemaProvider \DataflowSchemaProvider ;
11+ use Doctrine \DBAL \Schema \Comparator ;
1112use Doctrine \DBAL \Schema \Schema ;
1213use Doctrine \DBAL \Schema \Table ;
1314use Symfony \Component \Console \Attribute \AsCommand ;
@@ -31,7 +32,7 @@ public function __construct(private ConnectionFactory $connectionFactory)
3132 /**
3233 * {@inheritdoc}
3334 */
34- protected function configure ()
35+ protected function configure (): void
3536 {
3637 $ this
3738 ->setHelp ('The <info>%command.name%</info> help you to generate SQL Query to create or update your database schema for this bundle ' )
@@ -57,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5758 $ sqls = $ schema ->toSql ($ connection ->getDatabasePlatform ());
5859
5960 if ($ input ->getOption ('update ' )) {
60- $ sm = $ connection ->getSchemaManager ();
61+ $ sm = $ connection ->createSchemaManager ();
6162
6263 $ tableArray = [JobRepository::TABLE_NAME , ScheduledDataflowRepository::TABLE_NAME ];
6364 $ tables = [];
@@ -71,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7172 $ namespaces = [];
7273
7374 if ($ connection ->getDatabasePlatform ()->supportsSchemas ()) {
74- $ namespaces = $ sm ->listNamespaceNames ();
75+ $ namespaces = $ sm ->listSchemaNames ();
7576 }
7677
7778 $ sequences = [];
@@ -82,14 +83,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8283
8384 $ oldSchema = new Schema ($ tables , $ sequences , $ sm ->createSchemaConfig (), $ namespaces );
8485
85- $ sqls = $ schema -> getMigrateFromSql ( $ oldSchema , $ connection ->getDatabasePlatform ());
86+ $ sqls = $ connection -> getDatabasePlatform ()-> getAlterSchemaSQL (( new Comparator ( $ connection ->getDatabasePlatform ()))-> compareSchemas ( $ oldSchema , $ schema ));
8687 }
8788 $ io = new SymfonyStyle ($ input , $ output );
8889 $ io ->text ('Execute these SQL Queries on your database: ' );
8990 foreach ($ sqls as $ sql ) {
9091 $ io ->text ($ sql .'; ' );
9192 }
9293
93- return 0 ;
94+ return parent :: SUCCESS ;
9495 }
9596}
0 commit comments