<commit_before><?php

/*
 * This file is part of the broadway/broadway package.
 *
 * (c) <EMAIL> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Broadway\Bundle\BroadwayBundle\Command;

use Broadway\EventStore\DBALEventStore;
use Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand;
use Exception;
use RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Creates the event store schema.
 */
class SchemaEventStoreCreateCommand extends DoctrineCommand
{
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        $this
            ->setName('broadway:event-store:schema:init')
            ->setDescription('Creates the event store schema')
            ->setHelp(
<<<EOT
The <info>broadway:event-store:schema:init</info> command creates the schema in the default
connections database:

<info>php app/console broadway:schema:event_store:create</info>
EOT
            );
    }

    /**
     * {@inheritDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $connection = $this->getDoctrineConnection('default');

        $error = false;
        try {
            $schemaManager = $connection->getSchemaManager();
            $schema        = $schemaManager->createSchema();
            $eventStore    = $this->getEventStore();

            $table = $eventStore->configureSchema($schema);
            $schemaManager->createTable($table);

            $output->writeln('<info>Created schema</info>');
        } catch (Exception $e) {
            $output->writeln('<error>Could not create schema</error>');<commit_msg>check for existing table in schema init command<commit_after><?php

/*
 * This file is part of the broadway/broadway package.
 *
 * (c) <EMAIL> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Broadway\Bundle\BroadwayBundle\Command;

use Broadway\EventStore\DBALEventStore;
use Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand;
use Exception;
use RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Creates the event store schema.
 */
class SchemaEventStoreCreateCommand extends DoctrineCommand
{
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        $this
            ->setName('broadway:event-store:schema:init')
            ->setDescription('Creates the event store schema')
            ->setHelp(
<<<EOT
The <info>broadway:event-store:schema:init</info> command creates the schema in the default
connections database:

<info>php app/console broadway:schema:event_store:create</info>
EOT
            );
    }

    /**
     * {@inheritDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $connection = $this->getDoctrineConnection('default');

        $error = false;
        try {
            $schemaManager = $connection->getSchemaManager();
            $schema        = $schemaManager->createSchema();
            $eventStore    = $this->getEventStore();

            $table = $eventStore->configureSchema($schema);
            if (null !== $table) {
                $schemaManager->createTable($table);
                $output->writeln('<info>Created schema</info>');
            } else {
                $output->writeln('<info>Schema already created</info>');
            }
        } catch (Exception $e) {
            $output->writeln('<error>Could not create schema</error>');
{'fraction_non_alphanumeric': 0.1215927311598076, 'fraction_numerical': 0.0, 'mean_word_length': 2.919371727748691, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6650094', 'n_tokens_mistral': 997, 'n_tokens_neox': 986, 'n_words': 237}