mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
PHRAS-3820_fix-patch-3.8-to-4.1 (#4263)
* add --dry to bin/setup system:upgrade ; trace patches ; allow MailChecker to fail (when table 'usr' does not exist anymore...)
* MailChecker now works on 'usr' and 'Users' table
* typo
* typo again
* don't create appbox.Registrations if exists
* don't create tables if already exists
* Revert "don't create appbox.Registrations if exists"
This reverts commit 652131aff7
.
* drop (empty ?) tables already created before patch
* reorder drop / delete to follow fk rules
* fix typo that makes ApiMigration to run event when table exists ; Move some drop tables at the end
This commit is contained in:
@@ -18,8 +18,11 @@ use Alchemy\Phrasea\Core\Version\AppboxVersionRepository;
|
||||
use Alchemy\Phrasea\Databox\DataboxConnectionProvider;
|
||||
use Alchemy\Phrasea\Databox\DataboxRepository;
|
||||
use Alchemy\Phrasea\Filesystem\PhraseanetFilesystem as Filesystem;
|
||||
use Alchemy\Phrasea\Setup\Version\PreSchemaUpgrade\PreSchemaUpgradeCollection;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use MediaAlchemyst\Alchemyst;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpFoundation\File\File as SymfoFile;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@@ -182,14 +185,18 @@ class appbox extends base
|
||||
return self::BASE_TYPE;
|
||||
}
|
||||
|
||||
public function forceUpgrade(Setup_Upgrade $upgrader, Application $app)
|
||||
public function forceUpgrade(Setup_Upgrade $upgrader, Application $app, InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$dry = !!$input->getOption('dry');
|
||||
|
||||
$from_version = $this->get_version();
|
||||
|
||||
$app['phraseanet.cache-service']->flushAll();
|
||||
|
||||
// Executes stuff before applying patches
|
||||
$app['phraseanet.pre-schema-upgrader']->apply($app);
|
||||
/** @var PreSchemaUpgradeCollection $psu */
|
||||
$psu = $app['phraseanet.pre-schema-upgrader'];
|
||||
$psu->apply($app, $input, $output);
|
||||
|
||||
$finder = new Finder();
|
||||
$in = [];
|
||||
@@ -222,8 +229,8 @@ class appbox extends base
|
||||
|
||||
// do not apply patches
|
||||
// just update old database schema
|
||||
// it is need before applying patches
|
||||
$advices = $this->upgradeDB(false, $app);
|
||||
// it is needed before applying patches
|
||||
$advices = $this->upgradeDB(false, $input, $output);
|
||||
|
||||
// update also the doctrine table schema before applying patch
|
||||
if ($app['orm.em']->getConnection()->getDatabasePlatform()->supportsAlterTable()) {
|
||||
@@ -233,17 +240,17 @@ class appbox extends base
|
||||
}
|
||||
|
||||
foreach ($this->get_databoxes() as $s) {
|
||||
$advices = array_merge($advices, $s->upgradeDB(false, $app));
|
||||
$advices = array_merge($advices, $s->upgradeDB(false, $input, $output));
|
||||
}
|
||||
|
||||
// then apply patches
|
||||
$advices = $this->upgradeDB(true, $app);
|
||||
$advices = $this->upgradeDB(true, $input, $output);
|
||||
|
||||
foreach ($this->get_databoxes() as $s) {
|
||||
$advices = array_merge($advices, $s->upgradeDB(true, $app));
|
||||
$advices = array_merge($advices, $s->upgradeDB(true, $input, $output));
|
||||
}
|
||||
|
||||
$this->post_upgrade($app);
|
||||
$this->post_upgrade($app, $input, $output);
|
||||
|
||||
$app['phraseanet.cache-service']->flushAll();
|
||||
|
||||
@@ -261,14 +268,31 @@ class appbox extends base
|
||||
return $advices;
|
||||
}
|
||||
|
||||
protected function post_upgrade(Application $app)
|
||||
protected function post_upgrade(Application $app, InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->apply_patches($this->get_version(), $app['phraseanet.version']->getNumber(), true);
|
||||
$this->setVersion($app['phraseanet.version']);
|
||||
$dry = !!$input->getOption('dry');
|
||||
|
||||
$output->writeln(sprintf("into post_upgrade()"));
|
||||
$this->apply_patches($this->get_version(), $app['phraseanet.version']->getNumber(), true, $input, $output);
|
||||
/** @var Alchemy\Phrasea\Core\Version $phrVersion */
|
||||
$phrVersion = $app['phraseanet.version'];
|
||||
if($dry) {
|
||||
$output->writeln(sprintf("dry : NOT setting version of \"%s\" to %s", $this->get_dbname(), $phrVersion->getNumber()));
|
||||
}
|
||||
else {
|
||||
$output->writeln(sprintf("setting version of \"%s\" to %s", $this->get_dbname(), $phrVersion->getNumber()));
|
||||
$this->setVersion($phrVersion);
|
||||
}
|
||||
|
||||
foreach ($this->get_databoxes() as $databox) {
|
||||
$databox->apply_patches($databox->get_version(), $app['phraseanet.version']->getNumber(), true);
|
||||
$databox->setVersion($app['phraseanet.version']);
|
||||
$databox->apply_patches($databox->get_version(), $app['phraseanet.version']->getNumber(), true, $input, $output);
|
||||
if($dry) {
|
||||
$output->writeln(sprintf("dry : NOT setting version of \"%s\" to %s", $databox->get_dbname(), $phrVersion->getNumber()));
|
||||
}
|
||||
else {
|
||||
$output->writeln(sprintf("setting version of \"%s\" to %s", $databox->get_dbname(), $phrVersion->getNumber()));
|
||||
$databox->setVersion($app['phraseanet.version']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
Reference in New Issue
Block a user