Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@c9s
Created May 10, 2017 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c9s/2a10bda63a6a2c6a8f17f1a13d41a28e to your computer and use it in GitHub Desktop.
Save c9s/2a10bda63a6a2c6a8f17f1a13d41a28e to your computer and use it in GitHub Desktop.
<?php
public function migrate(Chunk $chunk, Shard $dstShard, array $schemas)
{
$shardId = $chunk->getShardId();
if ($dstShard->id === $shardId) {
throw new InvalidArgumentException("{$dstShard->id} == $shardId");
}
try {
$created = $this->clone($chunk, $dstShard, $schemas);
$missed = $this->verify($chunk, $dstShard, $schemas);
$deleted = $this->remove($chunk, $schemas);
return new MigrateResult(true, [
'created' => $created,
'missed' => $missed,
'deleted' => $deleted,
]);
} catch (MigrateException $e) {
$deleted = $this->removeFrom($chunk, $dstShard, $schemas);
return new MigrateResult(false, [
'deleted' => $deleted,
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment