PHRAS-2161_coll-id-in-log-docs_MASTER

moved cli "patch:log_coll_id" from bin/developer to bin/setup
cs
This commit is contained in:
Jean-Yves Gaulier
2018-07-31 11:56:50 +02:00
parent 9644efef00
commit 02efc2b9d1
3 changed files with 12 additions and 12 deletions

View File

@@ -22,7 +22,6 @@ use Alchemy\Phrasea\Command\Developer\RoutesDumper;
use Alchemy\Phrasea\Command\Developer\SetupTestsDbs; use Alchemy\Phrasea\Command\Developer\SetupTestsDbs;
use Alchemy\Phrasea\Command\Developer\Uninstaller; use Alchemy\Phrasea\Command\Developer\Uninstaller;
use Alchemy\Phrasea\Command\Developer\TranslationDumper; use Alchemy\Phrasea\Command\Developer\TranslationDumper;
use Alchemy\Phrasea\Command\Developer\FixLogCollId;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
@@ -79,7 +78,6 @@ $cli->command(new Uninstaller());
$cli->command(new JsFixtures()); $cli->command(new JsFixtures());
$cli->command(new IniReset()); $cli->command(new IniReset());
$cli->command(new SetupTestsDbs()); $cli->command(new SetupTestsDbs());
$cli->command(new FixLogCollId());
$cli->command(new \module_console_systemTemplateGenerator('system:generate-templates')); $cli->command(new \module_console_systemTemplateGenerator('system:generate-templates'));

View File

@@ -13,6 +13,7 @@ namespace KonsoleKommander;
use Alchemy\Phrasea\Command\Setup\ConfigurationEditor; use Alchemy\Phrasea\Command\Setup\ConfigurationEditor;
use Alchemy\Phrasea\Command\Setup\FixAutoincrements; use Alchemy\Phrasea\Command\Setup\FixAutoincrements;
use Alchemy\Phrasea\Command\Setup\FixLogCollId;
use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Core\Version;
use Alchemy\Phrasea\Command\UpgradeDBDatas; use Alchemy\Phrasea\Command\UpgradeDBDatas;
use Alchemy\Phrasea\Command\Setup\Install; use Alchemy\Phrasea\Command\Setup\Install;
@@ -78,6 +79,7 @@ $app->command(new CheckEnvironment('check:system'));
$app->command(new Install('system:install', $app['phraseanet.structure-template'])); $app->command(new Install('system:install', $app['phraseanet.structure-template']));
$app->command(new CrossDomainGenerator()); $app->command(new CrossDomainGenerator());
$app->command(new FixAutoincrements('system:fix-autoincrements')); $app->command(new FixAutoincrements('system:fix-autoincrements'));
$app->command(new FixLogCollId());
$app['phraseanet.setup_mode'] = true; $app['phraseanet.setup_mode'] = true;

View File

@@ -8,7 +8,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Command\Developer; namespace Alchemy\Phrasea\Command\Setup;
use Alchemy\Phrasea\Command\Command; use Alchemy\Phrasea\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
@@ -32,7 +32,7 @@ class FixLogCollId extends Command
private $databoxes; private $databoxes;
/** @var int */ /** @var int */
private $batchsize; private $batch_size;
/** @var bool */ /** @var bool */
private $dry; private $dry;
/** @var bool */ /** @var bool */
@@ -54,7 +54,7 @@ class FixLogCollId extends Command
$this->setDescription('Fix empty (null) coll_id in "log_docs" and "log_view" tables.'); $this->setDescription('Fix empty (null) coll_id in "log_docs" and "log_view" tables.');
$this->addOption('databox', null, InputOption::VALUE_OPTIONAL, 'Mandatory : The id (or dbname or viewname) of the databox'); $this->addOption('databox', null, InputOption::VALUE_OPTIONAL, 'Mandatory : The id (or dbname or viewname) of the databox');
$this->addOption('batchsize', null, InputOption::VALUE_OPTIONAL, 'work on a batch of n entries (default=100000)'); $this->addOption('batch_size', null, InputOption::VALUE_OPTIONAL, 'work on a batch of n entries (default=100000)');
$this->addOption('dry', null, InputOption::VALUE_NONE, 'dry run, list but don\'t act'); $this->addOption('dry', null, InputOption::VALUE_NONE, 'dry run, list but don\'t act');
$this->addOption('show_sql', null, InputOption::VALUE_NONE, 'show sql pre-selecting records'); $this->addOption('show_sql', null, InputOption::VALUE_NONE, 'show sql pre-selecting records');
$this->addOption('keep_tmp_table', null, InputOption::VALUE_NONE, 'keep the working "tmp_coll" table (help debug)'); $this->addOption('keep_tmp_table', null, InputOption::VALUE_NONE, 'keep the working "tmp_coll" table (help debug)');
@@ -99,16 +99,16 @@ class FixLogCollId extends Command
} }
// get options // get options
$this->batchsize = $input->getOption('batchsize'); $this->batch_size = $input->getOption('batch_size');
$this->show_sql = $input->getOption('show_sql') ? true : false; $this->show_sql = $input->getOption('show_sql') ? true : false;
$this->dry = $input->getOption('dry') ? true : false; $this->dry = $input->getOption('dry') ? true : false;
$this->keep_tmp_table = $input->getOption('keep_tmp_table') ? true : false; $this->keep_tmp_table = $input->getOption('keep_tmp_table') ? true : false;
if(is_null($this->batchsize)) { if(is_null($this->batch_size)) {
$this->batchsize = 100000; $this->batch_size = 100000;
} }
if($this->batchsize < 1) { if($this->batch_size < 1) {
$output->writeln(sprintf('<error>batchsize must be > 0</error>')); $output->writeln(sprintf('<error>batch_size must be > 0</error>'));
$argsOK = false; $argsOK = false;
} }
@@ -155,7 +155,7 @@ class FixLogCollId extends Command
'minmax' => [ 'minmax' => [
'msg' => "Get a batch", 'msg' => "Get a batch",
'sql' => "SELECT MIN(`id`) AS `minid`, MAX(`id`) AS `maxid` FROM\n" 'sql' => "SELECT MIN(`id`) AS `minid`, MAX(`id`) AS `maxid` FROM\n"
. " (SELECT `id` FROM `log_docs` WHERE ISNULL(`coll_id`) ORDER BY `id` DESC LIMIT " . $this->batchsize . ") AS `t", . " (SELECT `id` FROM `log_docs` WHERE ISNULL(`coll_id`) ORDER BY `id` DESC LIMIT " . $this->batch_size . ") AS `t",
'fetch' => false, 'fetch' => false,
'code' => function(ResultStatement $stmt) { 'code' => function(ResultStatement $stmt) {
$row = $stmt->fetch(); $row = $stmt->fetch();
@@ -211,7 +211,7 @@ class FixLogCollId extends Command
. " ON `tmp_colls`.`record_id` = `log_docs`.`record_id`\n" . " ON `tmp_colls`.`record_id` = `log_docs`.`record_id`\n"
. " AND `log_docs`.`id` >= `tmp_colls`.`from_id`\n" . " AND `log_docs`.`id` >= `tmp_colls`.`from_id`\n"
. " AND (`log_docs`.`id` < `tmp_colls`.`to_id` OR ISNULL(`tmp_colls`.`to_id`))\n" . " AND (`log_docs`.`id` < `tmp_colls`.`to_id` OR ISNULL(`tmp_colls`.`to_id`))\n"
. " SET `log_docs`.`coll_id` = `tmp_colls`.`coll_id", . " SET `log_docs`.`coll_id` = `tmp_colls`.`coll_id`",
'fetch' => false, 'fetch' => false,
'code' => null, 'code' => null,
'playdry' => self::PLAYDRY_NONE, 'playdry' => self::PLAYDRY_NONE,