/
Version20170802000000.php
55 lines (47 loc) · 1.72 KB
/
Version20170802000000.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Concrete\Core\Updater\Migrations\Migrations;
use Concrete\Core\Updater\Migrations\AbstractMigration;
use Concrete\Core\Updater\Migrations\RepeatableMigrationInterface;
class Version20170802000000 extends AbstractMigration implements RepeatableMigrationInterface
{
/**
* {@inheritdoc}
*
* @see \Doctrine\Migrations\AbstractMigration::getDescription()
*/
public function getDescription(): string
{
return '8.2.1';
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
*/
public function upgradeDatabase()
{
// First, we prune out all duplicates. We get the
// Listing from the table as it comes out of the database
// and we remove any rows that are after the first if they match.
$r = $this->connection->executeQuery('select * from btExpressEntryDetail');
$processed = [];
$delete = [];
while ($row = $r->fetch()) {
if (!in_array($row['bID'], $processed)) {
$processed[] = $row['bID'];
} else {
$delete[] = [
$row['bID'],
$row['exEntityID'],
$row['exSpecificEntryID'],
$row['exFormID'],
];
}
}
foreach ($delete as $deleteRow) {
$this->connection->executeQuery('delete from btExpressEntryDetail where bID = ? and exEntityID = ? and exSpecificEntryID = ? and exFormID = ?', $deleteRow);
}
// Now that we have removed problematic duplicate rows, rescan the table and remove the primary keys.
$this->refreshBlockType('express_entry_detail');
}
}