Created
January 26, 2015 16:03
-
-
Save roelvanduijnhoven/8eea449d255ca4b8cafb to your computer and use it in GitHub Desktop.
Update existing records for slm/queue-doctrine to latest version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function up(Schema $schema) | |
{ | |
$jobs = $this->connection->query(" | |
SELECT id, data | |
FROM queue_default | |
")->fetchAll(Query::HYDRATE_ARRAY); | |
foreach ($jobs as $job) { | |
// Skip already correct instances | |
$data = json_decode($job['data'], true); | |
if (!isset($data['class'])) { | |
continue; | |
} | |
// Adapt to queue structure since v4 | |
$data['metadata']['__name__'] = $data['class']; | |
unset($data['class']); | |
$this->connection->executeUpdate( | |
"UPDATE queue_default SET data = ? WHERE id = ?", | |
[json_encode($data), $job['id']] | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment