1
0
Fork 0
mirror of synced 2024-10-03 02:37:40 +13:00

Fix migration of floats

This commit is contained in:
Jake Barnby 2023-04-11 23:42:06 +12:00
parent 0f1c1fda9e
commit a2cb3c135f
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
3 changed files with 11 additions and 22 deletions

View file

@ -101,7 +101,7 @@ const APP_LIMIT_LIST_DEFAULT = 25; // Default maximum number of items to return
const APP_KEY_ACCCESS = 24 * 60 * 60; // 24 hours
const APP_CACHE_UPDATE = 24 * 60 * 60; // 24 hours
const APP_CACHE_BUSTER = 501;
const APP_VERSION_STABLE = '1.2.1';
const APP_VERSION_STABLE = '1.3.0';
const APP_DATABASE_ATTRIBUTE_EMAIL = 'email';
const APP_DATABASE_ATTRIBUTE_ENUM = 'enum';
const APP_DATABASE_ATTRIBUTE_IP = 'ip';

View file

@ -88,8 +88,8 @@ $cli
->setPDO($register->get('db'))
->execute();
} catch (\Throwable $th) {
throw $th;
Console::error('Failed to update project ("' . $project->getId() . '") version with error: ' . $th->getMessage());
throw $th;
}
clearProjectsCache($redis, $project);

View file

@ -41,10 +41,9 @@ class V18 extends Migration
$this->migrateCollections();
Console::info('Migrating Documents');
$this->forEachDocument([$this, 'migrateDocument']);
Console::info('Migrating Cache');
$this->forEachDocument([$this, 'migrateCache']);
$this->forEachDocument(function (Document $document) {
$this->migrateDocument($document);
});
}
/**
@ -59,15 +58,16 @@ class V18 extends Migration
$databaseTable = "database_{$database->getInternalId()}";
Console::info("Migrating Collections of {$database->getId()} ({$database->getAttribute('name')})");
foreach ($this->documentsIterator($databaseTable) as $collection) {
$collectionTable = "{$databaseTable}_collection_{$collection->getInternalId()}";
$floats = \array_filter($collection->getAttributes(), function ($attribute) {
return $attribute->getAttribute('type') === Database::VAR_FLOAT;
$floats = \array_filter($collection['attributes'] ?? [], function ($attribute) {
return $attribute['type'] === Database::VAR_FLOAT;
});
foreach ($floats as $attribute) {
$this->changeAttributeInternalType($collectionTable, $attribute->getId(), 'DOUBLE');
$this->changeAttributeInternalType($collectionTable, $attribute['key'], 'DOUBLE');
}
}
}
@ -85,12 +85,12 @@ class V18 extends Migration
Console::log("Migrating Collection \"{$id}\"");
$floats = \array_filter($collection, function ($attribute) {
$floats = \array_filter($collection['attributes'] ?? [], function ($attribute) {
return $attribute['type'] === Database::VAR_FLOAT;
});
foreach ($floats as $attribute) {
$this->changeAttributeInternalType($id, $attribute->getId(), 'DOUBLE');
$this->changeAttributeInternalType($id, $attribute['$id'], 'DOUBLE');
}
switch ($id) {
@ -146,15 +146,4 @@ class V18 extends Migration
return $document;
}
private function migrateCache(Document $document)
{
$key = "cache-_{$this->project->getInternalId()}:{$document->getCollection()}:{$document->getId()}";
$value = $this->redis->get($key);
if ($value) {
$this->redis->del($key);
$this->redis->set($key . ':*', $value);
}
}
}