/
Version20190509205043.php
41 lines (36 loc) · 1.52 KB
/
Version20190509205043.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
<?php
namespace Concrete\Core\Updater\Migrations\Migrations;
use Concrete\Core\Attribute\Category\CategoryService;
use Concrete\Core\Attribute\TypeFactory;
use Concrete\Core\Entity\Express\Control\Control;
use Concrete\Core\Entity\Express\Control\PublicIdentifierControl;
use Concrete\Core\Entity\Express\Entry;
use Concrete\Core\Express\Entry\PublicIdentifierGenerator;
use Concrete\Core\Updater\Migrations\AbstractMigration;
use Concrete\Core\Updater\Migrations\RepeatableMigrationInterface;
use Doctrine\ORM\EntityManager;
class Version20190509205043 extends AbstractMigration implements RepeatableMigrationInterface
{
public function upgradeDatabase()
{
$generator = new PublicIdentifierGenerator();
$this->refreshEntities([
Entry::class,
PublicIdentifierControl::class,
Control::class,
]);
// Now we have to populate this. Let's bust out of the entity manager for performance purposes.
$connection = $this->connection;
$this->connection->transactional(function() use ($connection, $generator) {
$r = $connection->executeQuery('select exEntryID from ExpressEntityEntries where publicIdentifier is null');
while ($row = $r->fetch()) {
$identifier = $generator->generate();
$connection->update(
'ExpressEntityEntries',
['publicIdentifier' => $identifier],
['exEntryID' => $row['exEntryID']]
);
}
});
}
}