Created
May 10, 2017 06:00
-
-
Save c9s/2a10bda63a6a2c6a8f17f1a13d41a28e to your computer and use it in GitHub Desktop.
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
<?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