Skip to content

Commit

Permalink
Migrate updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Sep 25, 2018
1 parent 73e318a commit 1d19e83
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions class/Common/Migrate.php
Expand Up @@ -27,12 +27,10 @@ class Migrate extends \Xmf\Database\Migrate

/**
* Migrate constructor.
* @throws \RuntimeException
* @throws \InvalidArgumentException
* @param \XoopsModules\Extgallery\Common\Configurator $configurator
*/
public function __construct(Extgallery\Common\Configurator $configurator)
{ require_once dirname(dirname(__DIR__)) . '/include/config.php';
// $config = getConfig();
$this->renameTables = $configurator->renameTables;

$moduleDirName = basename(dirname(dirname(__DIR__)));
Expand Down Expand Up @@ -75,25 +73,13 @@ private function convertIPAddresses($tableName, $columnName)
}

/**
* Move do* columns from extgallery_posts to extgallery_posts_text table
* Move columns to another table
*
* @return void
*/
private function moveDoColumns()
{
$tableName = 'extgallery_posts_text';
$srcTableName = 'extgallery_posts';
if (false !== $this->tableHandler->useTable($tableName)
&& false !== $this->tableHandler->useTable($srcTableName)) {
$attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml');
if (false === $attributes) {
$this->synchronizeTable($tableName);
$updateTable = $GLOBALS['xoopsDB']->prefix($tableName);
$joinTable = $GLOBALS['xoopsDB']->prefix($srcTableName);
$sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . ' , t1.doimage = t2.doimage, t1.dobr = t2.dobr';
$this->tableHandler->addToQueue($sql);
}
}
//for an example, see newbb 5.0
}

/**
Expand All @@ -107,12 +93,14 @@ private function moveDoColumns()
*/
protected function preSyncActions()
{
// change 'bb' table prefix to 'extgallery'
$this->changePrefix();
// columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point
$this->moveDoColumns();
// Convert IP address columns from int to readable varchar(45) for IPv6
$this->convertIPAddresses('extgallery_posts', 'poster_ip');
$this->convertIPAddresses('extgallery_report', 'reporter_ip');
// change table prefix
if (is_array($this->renameTables) && 0 < count($this->renameTables)) {
$this->changePrefix();
}
// // columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point
// $this->moveDoColumns();
// // Convert IP address columns from int to readable varchar(45) for IPv6
// $this->convertIPAddresses('extgallery_posts', 'poster_ip');
// $this->convertIPAddresses('extgallery_report', 'reporter_ip');
}
}

0 comments on commit 1d19e83

Please sign in to comment.