/**
  * Execute the console command.
  *
  * @param ConfigurationProvider  $provider
  * @param ManagerRegistry        $registry
  * @param SqlBuilder             $builder
  * @param MigrationFileGenerator $generator
  */
 public function fire(ConfigurationProvider $provider, ManagerRegistry $registry, SqlBuilder $builder, MigrationFileGenerator $generator)
 {
     $configuration = $provider->getForConnection($this->option('connection'));
     $em = $registry->getManager($this->option('connection'));
     $connection = $configuration->getConnection();
     // Overrule the filter
     if ($filterExpr = $this->option('filter-expression')) {
         $connection->getConfiguration()->setFilterSchemaAssetsExpression($filterExpr);
     }
     $fromSchema = $connection->getSchemaManager()->createSchema();
     $toSchema = $this->getSchemaProvider($em)->createSchema();
     // Drop tables which don't suffice to the filter regex
     if ($filterExpr = $connection->getConfiguration()->getFilterSchemaAssetsExpression()) {
         foreach ($toSchema->getTables() as $table) {
             $tableName = $table->getName();
             if (!preg_match($filterExpr, $this->resolveTableName($tableName))) {
                 $toSchema->dropTable($tableName);
             }
         }
     }
     $up = $builder->up($configuration, $fromSchema, $toSchema);
     $down = $builder->down($configuration, $fromSchema, $toSchema);
     if (!$up && !$down) {
         return $this->error('No changes detected in your mapping information.');
     }
     $path = $generator->generate($configuration, false, false, $up, $down);
     $this->line(sprintf('Generated new migration class to "<info>%s</info>" from schema differences.', $path));
 }
 public function test_can_generate_update_migration_file()
 {
     $filename = $this->generator->generate($this->configuration, false, 'users');
     $this->assertFileWasCreated($filename);
 }
 /**
  * Execute the console command.
  *
  * @param ConfigurationProvider  $provider
  * @param MigrationFileGenerator $generator
  */
 public function fire(ConfigurationProvider $provider, MigrationFileGenerator $generator)
 {
     $configuration = $provider->getForConnection();
     $filename = $generator->generate($configuration, $this->option('create'), $this->option('table'));
     $this->line(sprintf('<info>Created Migration:</info> %s', $filename));
 }