Skip to content

Instantly share code, notes, and snippets.

@roelvanduijnhoven
Created January 26, 2015 16:03
Show Gist options
  • Save roelvanduijnhoven/8eea449d255ca4b8cafb to your computer and use it in GitHub Desktop.
Save roelvanduijnhoven/8eea449d255ca4b8cafb to your computer and use it in GitHub Desktop.
Update existing records for slm/queue-doctrine to latest version
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