/
Version20180621222449.php
33 lines (27 loc) · 1.19 KB
/
Version20180621222449.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace Concrete\Core\Updater\Migrations\Migrations;
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Updater\Migrations\AbstractMigration;
use Concrete\Core\Updater\Migrations\RepeatableMigrationInterface;
use Doctrine\DBAL\Schema\Schema;
class Version20180621222449 extends AbstractMigration implements RepeatableMigrationInterface
{
public function upgradeDatabase()
{
$db = $this->connection;
if ($db->tableExists('atPageSelector')) {
// This is the name of the page selector attribute table in some implementations of the page selector attribute
// We need to take this data and place it into atNumber.
$r = $db->executeQuery('select * from atPageSelector');
while ($row = $r->fetch()) {
$db->transactional(function($db) use ($row) {
/** @var $db Connection */
$avID = $db->fetchColumn('select avID from atNumber where avID = ?', [$row['avID']]);
if (!$avID) {
$db->insert('atNumber', ['avID' => $row['avID'], 'value' => $row['value']]);
}
});
}
}
}
}