mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge branch '1.8.x' into feat-upgrade-runtimes
This commit is contained in:
commit
142e359dba
2 changed files with 51 additions and 1 deletions
|
|
@ -2345,7 +2345,7 @@ return [
|
||||||
'$id' => ID::custom('errors'),
|
'$id' => ID::custom('errors'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
'format' => '',
|
'format' => '',
|
||||||
'size' => 65535,
|
'size' => 1_000_000,
|
||||||
'signed' => true,
|
'signed' => true,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'default' => null,
|
'default' => null,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use Appwrite\Migration\Migration;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Utopia\CLI\Console;
|
use Utopia\CLI\Console;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Database\Database;
|
use Utopia\Database\Database;
|
||||||
use Utopia\Database\Document;
|
use Utopia\Database\Document;
|
||||||
use Utopia\Database\Exception\Conflict;
|
use Utopia\Database\Exception\Conflict;
|
||||||
|
|
@ -132,6 +133,13 @@ class V23 extends Migration
|
||||||
}
|
}
|
||||||
$this->dbForProject->purgeCachedCollection($id);
|
$this->dbForProject->purgeCachedCollection($id);
|
||||||
break;
|
break;
|
||||||
|
case 'migrations':
|
||||||
|
try {
|
||||||
|
$this->updateMigrateErrorSize();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("Failed to migration error attribute size in collection {$id}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -201,4 +209,46 @@ class V23 extends Migration
|
||||||
}
|
}
|
||||||
return $document;
|
return $document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update migration attribute size
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function updateMigrateErrorSize(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($this->project->getId() === 'console') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read-modify-write from the live schema to avoid overwriting unrelated changes.
|
||||||
|
$migration = $this->dbForProject->getCollection('migrations');
|
||||||
|
$attributes = $migration->getAttribute('attributes', []);
|
||||||
|
$attrsArray = \array_map(fn (Document $doc) => $doc->getArrayCopy(), $attributes);
|
||||||
|
$errorsIdx = \array_search('errors', \array_column($attrsArray, '$id'));
|
||||||
|
|
||||||
|
if ($errorsIdx === false) {
|
||||||
|
Console::warning("Skipping: 'errors' attribute not found in migrations collection for project {$this->project->getId()}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$desiredSize = 1_000_000;
|
||||||
|
$migrationAttributes = Config::getParam('collections', [])['projects']['migrations']['attributes'] ?? [];
|
||||||
|
$migrationIndex = \array_search('errors', \array_column($migrationAttributes, '$id'));
|
||||||
|
|
||||||
|
if ($migrationIndex !== false && isset($migrationAttributes[$migrationIndex]['size'])) {
|
||||||
|
$desiredSize = (int) $migrationAttributes[$migrationIndex]['size'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentSize = (int) ($attributes[$errorsIdx]['size'] ?? 0);
|
||||||
|
|
||||||
|
if ($currentSize === $desiredSize) {
|
||||||
|
Console::warning("Skipping: 'errors' attribute already of desired size {$desiredSize} in migrations collection for project {$this->project->getId()}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$attributes[$errorsIdx]['size'] = $desiredSize;
|
||||||
|
$migration->setAttribute('attributes', $attributes);
|
||||||
|
$this->dbForProject->updateDocument($migration->getCollection(), $migration->getId(), $migration);
|
||||||
|
$this->dbForProject->purgeCachedCollection('migrations');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue