public function importSchema()
    {
        // note: schema is built using Schema Builder event-driven API
        $schema = $this->schemaBuilder->buildSchema();
        $databasePlatform = $this->db->getDatabasePlatform();
        $queries = array_merge(
            $this->getDropSqlStatementsForExistingSchema($schema, $databasePlatform),
            // generate schema DDL queries
            $schema->toSql($databasePlatform)
        );

        $queriesCount = count($queries);
        $this->output->writeln(
            sprintf(
                '<info>Executing %d queries on database <comment>%s</comment> (<comment>%s</comment>)</info>',
                $queriesCount,
                $this->db->getDatabase(),
                $databasePlatform->getName()
            )
        );
        $progressBar = new ProgressBar($this->output);
        $progressBar->start($queriesCount);

        try {
            $this->db->beginTransaction();
            foreach ($queries as $query) {
                $this->db->exec($query);
                $progressBar->advance(1);
            }
            $this->db->commit();
        } catch (DBALException $e) {
            $this->db->rollBack();
            throw $e;
        }

        $progressBar->finish();
        // go to the next line after ProgressBar::finish
        $this->output->writeln('');
    }
public function importSchema()
    {
        // note: schema is built using Schema Builder event-driven API
        $schema = $this->schemaBuilder->buildSchema();
        $databasePlatform = $this->db->getDatabasePlatform();
        $queries = array_merge(
            $this->getDropSqlStatementsForExistingSchema($schema, $databasePlatform),
            // generate schema DDL queries
            $schema->toSql($databasePlatform)
        );

        $queriesCount = count($queries);
        $this->output->writeln(
            sprintf(
                '<info>Executing %d queries on database <comment>%s</comment> (<comment>%s</comment>)</info>',
                $queriesCount,
                $this->db->getDatabase(),
                $databasePlatform->getName()
            )
        );
        $progressBar = new ProgressBar($this->output);
        $progressBar->start($queriesCount);

        try {
            $this->db->beginTransaction();
            foreach ($queries as $query) {
                $this->db->exec($query);
                $progressBar->advance(1);
            }
            $this->db->commit();
        } catch (DBALException $e) {
            $this->db->rollBack();
            throw $e;
        }

        $progressBar->finish();
        // go to the next line after ProgressBar::finish
        $this->output->writeln('');
    }
public function importSchema ( ) { // note: schema is built using Schema Builder event-driven API $ schema = $ this -> schemaBuilder -> buildSchema ( ) ; $ databasePlatform = $ this -> db -> getDatabasePlatform ( ) ; $ queries = array_merge ( $ this -> getDropSqlStatementsForExistingSchema ( $ schema , $ databasePlatform ) , // generate schema DDL queries $ schema -> toSql ( $ databasePlatform ) ) ; $ queriesCount = count ( $ queries ) ; $ this -> output -> writeln ( sprintf ( '<info>Executing %d queries on database <comment>%s</comment> (<comment>%s</comment>)</info>' , $ queriesCount , $ this -> db -> getDatabase ( ) , $ databasePlatform -> getName ( ) ) ) ; $ progressBar = new ProgressBar ( $ this -> output ) ; $ progressBar -> start ( $ queriesCount ) ; try { $ this -> db -> beginTransaction ( ) ; foreach ( $ queries as $ query ) { $ this -> db -> exec ( $ query ) ; $ progressBar -> advance ( 1 ) ; } $ this -> db -> commit ( ) ; } catch ( DBALException $ e ) { $ this -> db -> rollBack ( ) ; throw $ e ; } $ progressBar -> finish ( ) ; // go to the next line after ProgressBar::finish $ this -> output -> writeln ( '' ) ; }
Import Schema using event-driven Schema Builder API from eZ Systems DoctrineSchema Bundle.

If you wish to extend schema, implement your own EventSubscriber

@see \EzSystems\DoctrineSchema\API\Event\SchemaBuilderEvent
@see \EzSystems\PlatformInstallerBundle\Event\Subscriber\BuildSchemaSubscriber

@throws \Doctrine\DBAL\DBALException
Import Schema using event - driven Schema Builder API from eZ Systems DoctrineSchema Bundle .