mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
Add Doctrine schema pre-upgrades
Conflicts: lib/classes/appbox.php
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Core\Provider;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Setup\ConfigurationTester;
|
use Alchemy\Phrasea\Setup\ConfigurationTester;
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Setup\Version\PreSchemaUpgrade\PreSchemaUpgradeCollection;
|
||||||
use Silex\Application as SilexApplication;
|
use Silex\Application as SilexApplication;
|
||||||
use Silex\ServiceProviderInterface;
|
use Silex\ServiceProviderInterface;
|
||||||
|
|
||||||
@@ -24,6 +25,10 @@ class ConfigurationTesterServiceProvider implements ServiceProviderInterface
|
|||||||
$app['phraseanet.configuration-tester'] = $app->share(function (Application $app) {
|
$app['phraseanet.configuration-tester'] = $app->share(function (Application $app) {
|
||||||
return new ConfigurationTester($app);
|
return new ConfigurationTester($app);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app['phraseanet.pre-schema-upgrader'] = $app->share(function () {
|
||||||
|
return new PreSchemaUpgradeCollection();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function boot(SilexApplication $app)
|
public function boot(SilexApplication $app)
|
||||||
|
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2013 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Setup\Version\PreSchemaUpgrade;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection of Doctrine schema pre-upgrades
|
||||||
|
*/
|
||||||
|
class PreSchemaUpgradeCollection
|
||||||
|
{
|
||||||
|
/** @var PreSchemaUpgradeInterface[] */
|
||||||
|
private $upgrades = array();
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2013 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Setup\Version\PreSchemaUpgrade;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for DB schema upgrade that have to be done before Doctrine schema
|
||||||
|
* upgrade
|
||||||
|
*/
|
||||||
|
interface PreSchemaUpgradeInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Applies the pre-upgrade/
|
||||||
|
*
|
||||||
|
* @param EntityManager $em
|
||||||
|
*/
|
||||||
|
public function apply(EntityManager $em);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the Upgrade is applyable
|
||||||
|
*
|
||||||
|
* @param Application $app
|
||||||
|
*
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
public function isApplyable(Application $app);
|
||||||
|
}
|
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2013 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Setup\Version\PreSchemaUpgrade;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
|
class Upgrade39 implements PreSchemaUpgradeInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function apply(EntityManager $em)
|
||||||
|
{
|
||||||
|
$em->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -295,6 +295,8 @@ class appbox extends base
|
|||||||
|
|
||||||
$upgrader->set_current_message($this->app->trans('Creating new tables'));
|
$upgrader->set_current_message($this->app->trans('Creating new tables'));
|
||||||
|
|
||||||
|
$app['phraseanet.pre-schema-upgrader']->apply($app);
|
||||||
|
|
||||||
$upgrader->add_steps_complete(1);
|
$upgrader->add_steps_complete(1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user