mirror of
https://github.com/appwrite/appwrite
synced 2026-05-22 08:28:42 +00:00
Ignore duplicate on create collection
This commit is contained in:
parent
fa3894ef1c
commit
d6fd05866a
1 changed files with 10 additions and 4 deletions
|
|
@ -158,7 +158,7 @@ abstract class Migration
|
|||
continue;
|
||||
}
|
||||
|
||||
Console::log('Migrating collection ' . $collection['$id'] . '...');
|
||||
Console::log('Migrating documents for collection "' . $collection['$id'] . '"');
|
||||
|
||||
$this->dbForProject->foreach($collection['$id'], function(Document $document) use ($collection, $callback) {
|
||||
if (empty($document->getId()) || empty($document->getCollection())) {
|
||||
|
|
@ -204,17 +204,23 @@ abstract class Migration
|
|||
};
|
||||
|
||||
if (!$this->dbForProject->getCollection($id)->isEmpty()) {
|
||||
$attributes = [];
|
||||
$indexes = [];
|
||||
$collection = $this->collections[$collectionType][$id];
|
||||
|
||||
$attributes = [];
|
||||
foreach ($collection['attributes'] as $attribute) {
|
||||
$attributes[] = new Document($attribute);
|
||||
}
|
||||
|
||||
$indexes = [];
|
||||
foreach ($collection['indexes'] as $index) {
|
||||
$indexes[] = new Document($index);
|
||||
}
|
||||
|
||||
$this->dbForProject->createCollection($name, $attributes, $indexes);
|
||||
try {
|
||||
$this->dbForProject->createCollection($name, $attributes, $indexes);
|
||||
} catch (Duplicate ) {
|
||||
Console::warning('Failed to create collection "' . $name . '": Collection already exists');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue