diff --git a/lib/Alchemy/Phrasea/Core/Provider/ConfigurationTesterServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ConfigurationTesterServiceProvider.php index 73109279fb..18e932b4fe 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ConfigurationTesterServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ConfigurationTesterServiceProvider.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Core\Provider; use Alchemy\Phrasea\Setup\ConfigurationTester; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Setup\Version\PreSchemaUpgrade\PreSchemaUpgradeCollection; use Silex\Application as SilexApplication; use Silex\ServiceProviderInterface; @@ -24,6 +25,10 @@ class ConfigurationTesterServiceProvider implements ServiceProviderInterface $app['phraseanet.configuration-tester'] = $app->share(function (Application $app) { return new ConfigurationTester($app); }); + + $app['phraseanet.pre-schema-upgrader'] = $app->share(function () { + return new PreSchemaUpgradeCollection(); + }); } public function boot(SilexApplication $app) diff --git a/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php new file mode 100644 index 0000000000..035896f35e --- /dev/null +++ b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php @@ -0,0 +1,42 @@ +upgrades[] = new Upgrade39(); + } + + /** + * Applies all applyable upgrades + * + * @param Application $app + */ + public function apply(Application $app) + { + foreach ($this->upgrades as $upgrade) { + if ($upgrade->isApplyable($app)) { + $upgrade->apply($app['EM']); + } + } + } +} diff --git a/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeInterface.php b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeInterface.php new file mode 100644 index 0000000000..e21f2423ff --- /dev/null +++ b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeInterface.php @@ -0,0 +1,38 @@ +getConnection()->executeQuery('RENAME TABLE `feeds` TO `feeds_backup`'); + } + + /** + * {@inheritdoc} + */ + public function isApplyable(Application $app) + { + $rs = $app['EM']->getConnection()->fetchAll('SHOW TABLE STATUS'); + $found = false; + + foreach ($rs as $row) { + if ('feeds' === $row['Name']) { + $found = true; + break; + } + } + + return $found; + } +} + diff --git a/lib/classes/appbox.php b/lib/classes/appbox.php index aa569f34cf..214b809c64 100644 --- a/lib/classes/appbox.php +++ b/lib/classes/appbox.php @@ -295,6 +295,8 @@ class appbox extends base $upgrader->set_current_message($this->app->trans('Creating new tables')); + $app['phraseanet.pre-schema-upgrader']->apply($app); + $upgrader->add_steps_complete(1); /**