From 97cf029ddefdd14776152ab6d414565347dbeda9 Mon Sep 17 00:00:00 2001 From: Sunil Talekar Date: Sun, 29 Mar 2020 16:17:33 +0530 Subject: [PATCH] Composer update to support SYmfony 4.4 --- Changelog.md | 13 + .../Command/DoctrineCommand.php | 77 ---- .../Command/Helper/DoctrineCommandHelper.php | 40 -- .../Command/MigrationsDiffDoctrineCommand.php | 55 --- .../MigrationsExecuteDoctrineCommand.php | 59 --- .../MigrationsGenerateDoctrineCommand.php | 59 --- .../MigrationsLatestDoctrineCommand.php | 59 --- .../MigrationsMigrateDoctrineCommand.php | 59 --- .../MigrationsStatusDoctrineCommand.php | 59 --- .../MigrationsVersionDoctrineCommand.php | 59 --- .../DependencyInjection/Configuration.php | 65 --- .../DoctrineMigrationsExtension.php | 58 --- .../DoctrineMigrationsBundle.php | 27 -- .../MigrationsBundle/Resources/doc/index.rst | 371 ------------------ DoctrineMigrationsBundle.php | 16 + .../Resources/meta/LICENSE => LICENSE | 0 README.markdown | 10 +- composer.json | 17 +- phpunit.xml.dist | 20 + 19 files changed, 64 insertions(+), 1059 deletions(-) create mode 100644 Changelog.md delete mode 100644 Doctrine/Bundle/MigrationsBundle/Command/DoctrineCommand.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/Command/Helper/DoctrineCommandHelper.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/Command/MigrationsDiffDoctrineCommand.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/Command/MigrationsExecuteDoctrineCommand.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/Command/MigrationsGenerateDoctrineCommand.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/Command/MigrationsLatestDoctrineCommand.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/Command/MigrationsMigrateDoctrineCommand.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/Command/MigrationsStatusDoctrineCommand.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/Command/MigrationsVersionDoctrineCommand.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/DependencyInjection/Configuration.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/DependencyInjection/DoctrineMigrationsExtension.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/DoctrineMigrationsBundle.php delete mode 100644 Doctrine/Bundle/MigrationsBundle/Resources/doc/index.rst create mode 100644 DoctrineMigrationsBundle.php rename Doctrine/Bundle/MigrationsBundle/Resources/meta/LICENSE => LICENSE (100%) create mode 100644 phpunit.xml.dist diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..7138a31 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,13 @@ +## 1.1.0 (2015-09-29) + +Features: + +* Allowed DoctrineMigrationsBundle to work with Symfony apps using DBAL only + +## 1.0.1 (2015-05-06) + +* Allowed Symfony 3.0 components + +## 1.0.0 (2014-08-17) + +Initial stable release diff --git a/Doctrine/Bundle/MigrationsBundle/Command/DoctrineCommand.php b/Doctrine/Bundle/MigrationsBundle/Command/DoctrineCommand.php deleted file mode 100644 index 7fbca14..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Command/DoctrineCommand.php +++ /dev/null @@ -1,77 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\Command; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Bundle\FrameworkBundle\Console\Application; -use Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand as BaseCommand; -use Doctrine\DBAL\Migrations\Configuration\Configuration; -use Doctrine\DBAL\Migrations\Configuration\AbstractFileConfiguration; - -/** - * Base class for Doctrine console commands to extend from. - * - * @author Fabien Potencier - */ -abstract class DoctrineCommand extends BaseCommand -{ - public static function configureMigrations(ContainerInterface $container, Configuration $configuration, $em) - { - if ($container->hasParameter('doctrine_migrations.default_entity_manager')) { - $configurationPrefix = 'doctrine_migrations.default_entity_manager'; - } elseif ($container->hasParameter('doctrine_migrations.' . $em)) { - $configurationPrefix = 'doctrine_migrations.' . $em; - } else { - if (null === $em) { - $message = 'There is no doctrine migrations configuration available for the default entity manager'; - } else { - $message = sprintf( - 'There is no doctrine migrations configuration available for the %s entity manager', - $em - ); - } - throw new \InvalidArgumentException($message); - } - - $containerParameters = $container->getParameter($configurationPrefix); - - $dir = $containerParameters['dir_name']; - if (!file_exists($dir)) { - mkdir($dir, 0777, true); - } - - $configuration->setMigrationsNamespace($containerParameters['namespace']); - $configuration->setMigrationsDirectory($dir); - $configuration->registerMigrationsFromDirectory($dir); - $configuration->setName($containerParameters['name']); - $configuration->setMigrationsTableName($containerParameters['table_name']); - - self::injectContainerToMigrations($container, $configuration->getMigrations()); - } - - /** - * Injects the container to migrations aware of it - */ - private static function injectContainerToMigrations(ContainerInterface $container, array $versions) - { - foreach ($versions as $version) { - $migration = $version->getMigration(); - if ($migration instanceof ContainerAwareInterface) { - $migration->setContainer($container); - } - } - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/Command/Helper/DoctrineCommandHelper.php b/Doctrine/Bundle/MigrationsBundle/Command/Helper/DoctrineCommandHelper.php deleted file mode 100644 index 18fffec..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Command/Helper/DoctrineCommandHelper.php +++ /dev/null @@ -1,40 +0,0 @@ - - * (c) Doctrine Project, Guilehrme Blanco - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\Command\Helper; - -use Doctrine\Bundle\DoctrineBundle\Command\Proxy\DoctrineCommandHelper as BaseDoctrineCommandHelper; -use Symfony\Bundle\FrameworkBundle\Console\Application; -use Symfony\Component\Console\Input\InputInterface; - -/** - * Provides some helper and convenience methods to configure doctrine commands in the context of bundles - * and multiple connections/entity managers. - * - * @author Guilherme Blanco - */ -abstract class DoctrineCommandHelper extends BaseDoctrineCommandHelper -{ - public static function setApplicationHelper(Application $application, InputInterface $input) - { - $doctrine = $application->getKernel()->getContainer()->get('doctrine'); - $managerNames = $doctrine->getManagerNames(); - - if (empty($managerNames)) { - self::setApplicationConnection($application, $input->getOption('db')); - } else { - self::setApplicationEntityManager($application, $input->getOption('em')); - } - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsDiffDoctrineCommand.php b/Doctrine/Bundle/MigrationsBundle/Command/MigrationsDiffDoctrineCommand.php deleted file mode 100644 index 769899c..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsDiffDoctrineCommand.php +++ /dev/null @@ -1,55 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\Command; - -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputOption; -use Doctrine\Bundle\DoctrineBundle\Command\Proxy\DoctrineCommandHelper; -use Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand; - -/** - * Command for generate migration classes by comparing your current database schema - * to your mapping information. - * - * @author Fabien Potencier - * @author Jonathan H. Wage - */ -class MigrationsDiffDoctrineCommand extends DiffCommand -{ - protected function configure() - { - parent::configure(); - - $this - ->setName('doctrine:migrations:diff') - ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command.') - ; - } - - public function execute(InputInterface $input, OutputInterface $output) - { - DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em')); - - $configuration = $this->getMigrationConfiguration($input, $output); - DoctrineCommand::configureMigrations( - $this->getApplication()->getKernel()->getContainer(), - $configuration, - $input->getOption('em') - ); - - parent::execute($input, $output); - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsExecuteDoctrineCommand.php b/Doctrine/Bundle/MigrationsBundle/Command/MigrationsExecuteDoctrineCommand.php deleted file mode 100644 index bd6b126..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsExecuteDoctrineCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\Command; - -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputOption; -use Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand; - -/** - * Command for executing single migrations up or down manually. - * - * @author Fabien Potencier - * @author Jonathan H. Wage - */ -class MigrationsExecuteDoctrineCommand extends ExecuteCommand -{ - protected function configure() - { - parent::configure(); - - $this - ->setName('doctrine:migrations:execute') - ->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') - ; - } - - public function execute(InputInterface $input, OutputInterface $output) - { - // EM and DB options cannot be set at same time - if (null !== $input->getOption('em') && null !== $input->getOption('db')) { - throw new \InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); - } - - Helper\DoctrineCommandHelper::setApplicationHelper($this->getApplication(), $input); - - $configuration = $this->getMigrationConfiguration($input, $output); - DoctrineCommand::configureMigrations( - $this->getApplication()->getKernel()->getContainer(), - $configuration, - $input->getOption('em') - ); - - parent::execute($input, $output); - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsGenerateDoctrineCommand.php b/Doctrine/Bundle/MigrationsBundle/Command/MigrationsGenerateDoctrineCommand.php deleted file mode 100644 index cd0bb3e..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsGenerateDoctrineCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\Command; - -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputOption; -use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand; - -/** - * Command for generating new blank migration classes - * - * @author Fabien Potencier - * @author Jonathan H. Wage - */ -class MigrationsGenerateDoctrineCommand extends GenerateCommand -{ - protected function configure() - { - parent::configure(); - - $this - ->setName('doctrine:migrations:generate') - ->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') - ; - } - - public function execute(InputInterface $input, OutputInterface $output) - { - // EM and DB options cannot be set at same time - if (null !== $input->getOption('em') && null !== $input->getOption('db')) { - throw new \InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); - } - - Helper\DoctrineCommandHelper::setApplicationHelper($this->getApplication(), $input); - - $configuration = $this->getMigrationConfiguration($input, $output); - DoctrineCommand::configureMigrations( - $this->getApplication()->getKernel()->getContainer(), - $configuration, - $input->getOption('em') - ); - - parent::execute($input, $output); - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsLatestDoctrineCommand.php b/Doctrine/Bundle/MigrationsBundle/Command/MigrationsLatestDoctrineCommand.php deleted file mode 100644 index 8365979..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsLatestDoctrineCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\Command; - -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputOption; -use Doctrine\DBAL\Migrations\Tools\Console\Command\LatestCommand; - -/** - * Command for outputting the latest version number. - * - * @author Fabien Potencier - * @author Jonathan H. Wage - */ -class MigrationsLatestDoctrineCommand extends LatestCommand -{ - protected function configure() - { - parent::configure(); - - $this - ->setName('doctrine:migrations:latest') - ->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') - ; - } - - public function execute(InputInterface $input, OutputInterface $output) - { - // EM and DB options cannot be set at same time - if (null !== $input->getOption('em') && null !== $input->getOption('db')) { - throw new \InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); - } - - Helper\DoctrineCommandHelper::setApplicationHelper($this->getApplication(), $input); - - $configuration = $this->getMigrationConfiguration($input, $output); - DoctrineCommand::configureMigrations( - $this->getApplication()->getKernel()->getContainer(), - $configuration, - $input->getOption('em') - ); - - parent::execute($input, $output); - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsMigrateDoctrineCommand.php b/Doctrine/Bundle/MigrationsBundle/Command/MigrationsMigrateDoctrineCommand.php deleted file mode 100644 index fe5f76d..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsMigrateDoctrineCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\Command; - -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputOption; -use Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand; - -/** - * Command for executing a migration to a specified version or the latest available version. - * - * @author Fabien Potencier - * @author Jonathan H. Wage - */ -class MigrationsMigrateDoctrineCommand extends MigrateCommand -{ - protected function configure() - { - parent::configure(); - - $this - ->setName('doctrine:migrations:migrate') - ->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') - ; - } - - public function execute(InputInterface $input, OutputInterface $output) - { - // EM and DB options cannot be set at same time - if (null !== $input->getOption('em') && null !== $input->getOption('db')) { - throw new \InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); - } - - Helper\DoctrineCommandHelper::setApplicationHelper($this->getApplication(), $input); - - $configuration = $this->getMigrationConfiguration($input, $output); - DoctrineCommand::configureMigrations( - $this->getApplication()->getKernel()->getContainer(), - $configuration, - $input->getOption('em') - ); - - parent::execute($input, $output); - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsStatusDoctrineCommand.php b/Doctrine/Bundle/MigrationsBundle/Command/MigrationsStatusDoctrineCommand.php deleted file mode 100644 index ccfdde7..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsStatusDoctrineCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\Command; - -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputOption; -use Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand; - -/** - * Command to view the status of a set of migrations. - * - * @author Fabien Potencier - * @author Jonathan H. Wage - */ -class MigrationsStatusDoctrineCommand extends StatusCommand -{ - protected function configure() - { - parent::configure(); - - $this - ->setName('doctrine:migrations:status') - ->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') - ; - } - - public function execute(InputInterface $input, OutputInterface $output) - { - // EM and DB options cannot be set at same time - if (null !== $input->getOption('em') && null !== $input->getOption('db')) { - throw new \InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); - } - - Helper\DoctrineCommandHelper::setApplicationHelper($this->getApplication(), $input); - - $configuration = $this->getMigrationConfiguration($input, $output); - DoctrineCommand::configureMigrations( - $this->getApplication()->getKernel()->getContainer(), - $configuration, - $input->getOption('em') - ); - - parent::execute($input, $output); - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsVersionDoctrineCommand.php b/Doctrine/Bundle/MigrationsBundle/Command/MigrationsVersionDoctrineCommand.php deleted file mode 100644 index e112aa3..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Command/MigrationsVersionDoctrineCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\Command; - -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputOption; -use Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand; - -/** - * Command for manually adding and deleting migration versions from the version table. - * - * @author Fabien Potencier - * @author Jonathan H. Wage - */ -class MigrationsVersionDoctrineCommand extends VersionCommand -{ - protected function configure() - { - parent::configure(); - - $this - ->setName('doctrine:migrations:version') - ->addOption('db', null, InputOption::VALUE_REQUIRED, 'The database connection to use for this command.') - ->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') - ; - } - - public function execute(InputInterface $input, OutputInterface $output) - { - // EM and DB options cannot be set at same time - if (null !== $input->getOption('em') && null !== $input->getOption('db')) { - throw new \InvalidArgumentException('Cannot set both "em" and "db" for command execution.'); - } - - Helper\DoctrineCommandHelper::setApplicationHelper($this->getApplication(), $input); - - $configuration = $this->getMigrationConfiguration($input, $output); - DoctrineCommand::configureMigrations( - $this->getApplication()->getKernel()->getContainer(), - $configuration, - $input->getOption('em') - ); - - parent::execute($input, $output); - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/DependencyInjection/Configuration.php b/Doctrine/Bundle/MigrationsBundle/DependencyInjection/Configuration.php deleted file mode 100644 index dc79138..0000000 --- a/Doctrine/Bundle/MigrationsBundle/DependencyInjection/Configuration.php +++ /dev/null @@ -1,65 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\DependencyInjection; - -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; - -/** - * DoctrineMigrationsExtension configuration structure. - * - * @author Lukas Kahwe Smith - */ -class Configuration implements ConfigurationInterface -{ - /** - * Generates the configuration tree. - * - * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The config tree builder - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('doctrine_migrations', 'array'); - - $rootNode - ->beforeNormalization() - ->ifTrue(function($v) { - if(empty($v)) { - return true; - } - $firstConfigValue = array_shift($v); - - return !is_array($firstConfigValue); - }) - ->then(function($v) { - $v = array('default_entity_manager' => $v); - - return $v; - }) - ->end() - ->useAttributeAsKey('name') - ->prototype('array') - ->children() - ->scalarNode('dir_name')->defaultValue('%kernel.root_dir%/DoctrineMigrations')->cannotBeEmpty()->end() - ->scalarNode('namespace')->defaultValue('Application\Migrations')->cannotBeEmpty()->end() - ->scalarNode('table_name')->defaultValue('migration_versions')->cannotBeEmpty()->end() - ->scalarNode('name')->defaultValue('Application Migrations')->end() - ->end() - ; - - return $treeBuilder; - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/DependencyInjection/DoctrineMigrationsExtension.php b/Doctrine/Bundle/MigrationsBundle/DependencyInjection/DoctrineMigrationsExtension.php deleted file mode 100644 index 5d7d94f..0000000 --- a/Doctrine/Bundle/MigrationsBundle/DependencyInjection/DoctrineMigrationsExtension.php +++ /dev/null @@ -1,58 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; - -/** - * DoctrineMigrationsExtension. - * - * @author Lukas Kahwe Smith - */ -class DoctrineMigrationsExtension extends Extension -{ - /** - * Responds to the migrations configuration parameter. - * - * @param array $configs - * @param ContainerBuilder $container - */ - public function load(array $configs, ContainerBuilder $container) - { - $configuration = new Configuration(); - - $config = $this->processConfiguration($configuration, $configs); - - foreach ($config as $key => $value) { - $container->setParameter($this->getAlias().'.'.$key, $value); - } - } - - /** - * Returns the base path for the XSD files. - * - * @return string The XSD base path - */ - public function getXsdValidationBasePath() - { - return __DIR__.'/../Resources/config/schema'; - } - - public function getNamespace() - { - return 'http://symfony.com/schema/dic/doctrine/migrations'; - } -} diff --git a/Doctrine/Bundle/MigrationsBundle/DoctrineMigrationsBundle.php b/Doctrine/Bundle/MigrationsBundle/DoctrineMigrationsBundle.php deleted file mode 100644 index 77fb627..0000000 --- a/Doctrine/Bundle/MigrationsBundle/DoctrineMigrationsBundle.php +++ /dev/null @@ -1,27 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\MigrationsBundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -/** - * Bundle. - * - * @author Fabien Potencier - * @author Jonathan H. Wage - */ -class DoctrineMigrationsBundle extends Bundle -{ -} diff --git a/Doctrine/Bundle/MigrationsBundle/Resources/doc/index.rst b/Doctrine/Bundle/MigrationsBundle/Resources/doc/index.rst deleted file mode 100644 index 3131d3d..0000000 --- a/Doctrine/Bundle/MigrationsBundle/Resources/doc/index.rst +++ /dev/null @@ -1,371 +0,0 @@ -DoctrineMigrationsBundle -======================== - -The database migrations feature is an extension of the database abstraction -layer and offers you the ability to programmatically deploy new versions of -your database schema in a safe, easy and standardized way. - -.. tip:: - - You can read more about the Doctrine Database Migrations on the project's - `documentation`_. - -Installation ------------- - -Doctrine migrations for Symfony are maintained in the `DoctrineMigrationsBundle`_. -The bundle uses external `Doctrine Database Migrations`_ library. - -Follow these steps to install the bundle and the library in the Symfony -Standard edition. Add the following to your ``composer.json`` file: - -.. code-block:: json - - { - "require": { - "doctrine/migrations": "1.0.*@dev", - "doctrine/doctrine-migrations-bundle": "1.0.*" - } - } - -Update the vendor libraries: - -.. code-block:: bash - - $ php composer.phar update - -If everything worked, the ``DoctrineMigrationsBundle`` can now be found -at ``vendor/doctrine/doctrine-migrations-bundle``. - -.. note:: - - ``DoctrineMigrationsBundle`` installs - `Doctrine Database Migrations`_ library. The library can be found - at ``vendor/doctrine/migrations``. - -Finally, be sure to enable the bundle in ``AppKernel.php`` by including the -following: - -.. code-block:: php - - // app/AppKernel.php - public function registerBundles() - { - $bundles = array( - //... - new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), - ); - } - -Configuration -------------- - -You can configure the path, namespace, table_name and name in your `config.yml`. The examples below are the default values. - -.. code-block:: yaml - - // app/config/config.yml - doctrine_migrations: - dir_name: %kernel.root_dir%/DoctrineMigrations - namespace: Application\Migrations - table_name: migration_versions - name: Application Migrations - -Usage ------ - -All of the migrations functionality is contained in a few console commands: - -.. code-block:: bash - - doctrine:migrations - :diff Generate a migration by comparing your current database to your mapping information. - :execute Execute a single migration version up or down manually. - :generate Generate a blank migration class. - :migrate Execute a migration to a specified version or the latest available version. - :status View the status of a set of migrations. - :version Manually add and delete migration versions from the version table. - -Start by getting the status of migrations in your application by running -the ``status`` command: - -.. code-block:: bash - - php app/console doctrine:migrations:status - - == Configuration - - >> Name: Application Migrations - >> Configuration Source: manually configured - >> Version Table Name: migration_versions - >> Migrations Namespace: Application\Migrations - >> Migrations Directory: /path/to/project/app/DoctrineMigrations - >> Current Version: 0 - >> Latest Version: 0 - >> Executed Migrations: 0 - >> Available Migrations: 0 - >> New Migrations: 0 - -Now, you can start working with migrations by generating a new blank migration -class. Later, you'll learn how Doctrine can generate migrations automatically -for you. - -.. code-block:: bash - - php app/console doctrine:migrations:generate - Generated new migration class to "/path/to/project/app/DoctrineMigrations/Version20100621140655.php" - -Have a look at the newly generated migration class and you will see something -like the following:: - - namespace Application\Migrations; - - use Doctrine\DBAL\Migrations\AbstractMigration, - Doctrine\DBAL\Schema\Schema; - - class Version20100621140655 extends AbstractMigration - { - public function up(Schema $schema) - { - - } - - public function down(Schema $schema) - { - - } - } - -If you run the ``status`` command it will now show that you have one new -migration to execute: - -.. code-block:: bash - - php app/console doctrine:migrations:status --show-versions - - == Configuration - - >> Name: Application Migrations - >> Configuration Source: manually configured - >> Version Table Name: migration_versions - >> Migrations Namespace: Application\Migrations - >> Migrations Directory: /path/to/project/app/DoctrineMigrations - >> Current Version: 0 - >> Latest Version: 2010-06-21 14:06:55 (20100621140655) - >> Executed Migrations: 0 - >> Available Migrations: 1 - >> New Migrations: 1 - - == Migration Versions - - >> 2010-06-21 14:06:55 (20100621140655) not migrated - -Now you can add some migration code to the ``up()`` and ``down()`` methods and -finally migrate when you're ready: - -.. code-block:: bash - - php app/console doctrine:migrations:migrate 20100621140655 - -For more information on how to write the migrations themselves (i.e. how to -fill in the ``up()`` and ``down()`` methods), see the official Doctrine Migrations -`documentation`_. - -Running Migrations during Deployment -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Of course, the end goal of writing migrations is to be able to use them to -reliably update your database structure when you deploy your application. -By running the migrations locally (or on a beta server), you can ensure that -the migrations work as you expect. - -When you do finally deploy your application, you just need to remember to run -the ``doctrine:migrations:migrate`` command. Internally, Doctrine creates -a ``migration_versions`` table inside your database and tracks which migrations -have been executed there. So, no matter how many migrations you've created -and executed locally, when you run the command during deployment, Doctrine -will know exactly which migrations it hasn't run yet by looking at the ``migration_versions`` -table of your production database. Regardless of what server you're on, you -can always safely run this command to execute only the migrations that haven't -been run yet on *that* particular database. - -Generating Migrations Automatically ------------------------------------ - -In reality, you should rarely need to write migrations manually, as the migrations -library can generate migration classes automatically by comparing your Doctrine -mapping information (i.e. what your database *should* look like) with your -actual current database structure. - -For example, suppose you create a new ``User`` entity and add mapping information -for Doctrine's ORM: - -.. configuration-block:: - - .. code-block:: php-annotations - - // src/Acme/HelloBundle/Entity/User.php - namespace Acme\HelloBundle\Entity; - - use Doctrine\ORM\Mapping as ORM; - - /** - * @ORM\Entity - * @ORM\Table(name="hello_user") - */ - class User - { - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue(strategy="AUTO") - */ - protected $id; - - /** - * @ORM\Column(type="string", length=255) - */ - protected $name; - } - - .. code-block:: yaml - - # src/Acme/HelloBundle/Resources/config/doctrine/User.orm.yml - Acme\HelloBundle\Entity\User: - type: entity - table: hello_user - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 255 - - .. code-block:: xml - - - - - - - - - - - - - -With this information, Doctrine is now ready to help you persist your new -``User`` object to and from the ``hello_user`` table. Of course, this table -doesn't exist yet! Generate a new migration for this table automatically by -running the following command: - -.. code-block:: bash - - php app/console doctrine:migrations:diff - -You should see a message that a new migration class was generated based on -the schema differences. If you open this file, you'll find that it has the -SQL code needed to create the ``hello_user`` table. Next, run the migration -to add the table to your database: - -.. code-block:: bash - - php app/console doctrine:migrations:migrate - -The moral of the story is this: after each change you make to your Doctrine -mapping information, run the ``doctrine:migrations:diff`` command to automatically -generate your migration classes. - -If you do this from the very beginning of your project (i.e. so that even -the first tables were loaded via a migration class), you'll always be able -to create a fresh database and run your migrations in order to get your database -schema fully up to date. In fact, this is an easy and dependable workflow -for your project. - -Container Aware Migrations --------------------------- - -In some cases you might need access to the container to ensure the proper update of -your data structure. This could be necessary to update relations with some specific -logic or to create new entities. - -Therefore you can just implement the ContainerAwareInterface with its needed methods -to get full access to the container. - -.. code-block:: php - - // ... - use Symfony\Component\DependencyInjection\ContainerAwareInterface; - use Symfony\Component\DependencyInjection\ContainerInterface; - - class Version20130326212938 extends AbstractMigration implements ContainerAwareInterface - { - - private $container; - - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } - - public function up(Schema $schema) - { - // ... migration content - } - - public function postUp(Schema $schema) - { - $converter = $this->container->get('my_service.convert_data_to'); - // ... convert the data from markdown to html for instance - } - } - -Manual Tables -------------- - -It is a common use case, that in addition to your generated database structure -based on your doctrine entities you might need custom tables. By default such -tables will be removed by the doctrine:migrations:diff command. - -If you follow a specific scheme you can configure doctrine/dbal to ignore those -tables. Let's say all custom tables will be prefixed by ``t_``. In this case you -just have to add the following configuration option to your doctrine configuration: - -.. configuration-block:: - - .. code-block:: yaml - - doctrine: - dbal: - schema_filter: ~^(?!t_)~ - - .. code-block:: xml - - - - - .. code-block:: php - - $container->loadFromExtension('doctrine', array( - 'dbal' => array( - 'schema_filter' => '~^(?!t_)~', - // ... - ), - // ... - )); - -This ignores the tables on the DBAL level and they will be ignored by the diff command. - -Note that if you have multiple connections configured then the ``schema_filter`` configuration -will need to be placed per-connection. - -.. _documentation: http://docs.doctrine-project.org/projects/doctrine-migrations/en/latest/index.html -.. _DoctrineMigrationsBundle: https://github.com/doctrine/DoctrineMigrationsBundle -.. _`Doctrine Database Migrations`: https://github.com/doctrine/migrations diff --git a/DoctrineMigrationsBundle.php b/DoctrineMigrationsBundle.php new file mode 100644 index 0000000..a9b438d --- /dev/null +++ b/DoctrineMigrationsBundle.php @@ -0,0 +1,16 @@ + + * @author Jonathan H. Wage + */ +class DoctrineMigrationsBundle extends Bundle +{ +} diff --git a/Doctrine/Bundle/MigrationsBundle/Resources/meta/LICENSE b/LICENSE similarity index 100% rename from Doctrine/Bundle/MigrationsBundle/Resources/meta/LICENSE rename to LICENSE diff --git a/README.markdown b/README.markdown index 48dc1cc..dac34f8 100644 --- a/README.markdown +++ b/README.markdown @@ -1,8 +1,10 @@ DoctrineMigrationsBundle ======================== +Doctrine Migration support for ICC premiumAccess: -This bundle integrates the [Doctrine2 Migrations library](http://www.doctrine-project.org/projects/migrations.html). -into Symfony so that you can safely and quickly manage database migrations. +This bundle integrates the [Doctrine2 Migrations library](http://www.doctrine-project.org/projects/migrations.html) +into Symfony applications. Database migrations help you version the changes in +your database schema and apply them in a predictable way on every server running +the application. -Documentation on how to install and use this bundle is available in the -Symfony2 [documentation](http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html). +[Read the documentation of this bundle](https://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html). diff --git a/composer.json b/composer.json index 69713e2..b8faf78 100644 --- a/composer.json +++ b/composer.json @@ -10,14 +10,15 @@ } ], "require": { - "php": "~7.4", - "symfony/framework-bundle": "4.0.*", - "doctrine/doctrine-bundle": "^1.10.3", - "doctrine/migrations": "~1.0@dev" + "php": ">=5.4.0", + "symfony/framework-bundle": "~2.7|~3.3|~4.0", + "doctrine/doctrine-bundle": "~1.0", + "doctrine/migrations": "^1.1" }, - "autoload": { - "psr-0": { "Doctrine\\Bundle\\MigrationsBundle": "" } + "require-dev": { + "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^7.4" }, - "target-dir": "Doctrine/Bundle/MigrationsBundle", - "minimum-stability": "dev" + "autoload": { + "psr-4": { "Doctrine\\Bundle\\MigrationsBundle\\": "" } + } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..720c51a --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,20 @@ + + + + + + ./Tests + + + + + + . + + ./Resources + ./Tests + ./vendor + + + +