Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:OpenConext/Stepup-Middleware int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
pmeulen committed Aug 19, 2021
2 parents a44ab29 + 0399f44 commit d2e1ebc
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/Surfnet/Migrations/Version20210610131957.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ final class Version20210610131957 extends AbstractMigration

private static $update = <<<SQL
UPDATE event_stream
SET payload = '%s'
WHERE uuid = '%s'
AND playhead = %s;
SET payload = :payload
WHERE uuid = :uuid
AND playhead = :playhead;
SQL;

public function up(Schema $schema) : void
Expand All @@ -36,23 +36,28 @@ public function up(Schema $schema) : void
$this->addSql('# Updating entities.');

$affectedEventStreamRows = $this->connection->executeQuery(self::$select);

$this->write("<info>Affected records: {$affectedEventStreamRows->rowCount()}</info>");

if ($affectedEventStreamRows->rowCount() === 0) {
return;
}

foreach ($affectedEventStreamRows as $eventStream) {
$rawPayload = $eventStream['payload'];
$uuid = $eventStream['uuid'];
$playhead = $eventStream['playhead'];

$payload = $this->stripSensitiveData($rawPayload);
$this->write("<info>Migating: {$uuid}#{$playhead}</info>");

$payload = $this->stripSensitiveData($rawPayload);
$this->connection->executeUpdate(
sprintf(
self::$update,
$payload,
$uuid,
$playhead
)
self::$update,
[
'payload' => $payload,
'uuid' => $uuid,
'playhead' => $playhead,
]
);
}
}
Expand Down

0 comments on commit d2e1ebc

Please sign in to comment.