added patch script for adding database dsn in the databases collection

This commit is contained in:
ArnabChatterjee20k
2025-10-07 13:18:11 +05:30
parent f5ea19b15d
commit 88f2b1ad50
+12 -1
View File
@@ -8,6 +8,7 @@ use Throwable;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\System\System;
class V23 extends Migration
{
@@ -47,6 +48,16 @@ class V23 extends Migration
// so first creating the attribute then bulk updating the attribute
$this->createAttributeFromCollection($this->dbForProject, 'databases', 'type');
$this->dbForProject->updateDocuments('databases', new Document(['type' => 'legacy']));
}
// database dsn
$database = System::getEnv('_APP_DATABASE_NAME', 'appwrite');
$namespace = System::getEnv('_APP_DATABASE_SHARED_NAMESPACE', '');
$schema = System::getEnv('_APP_DB_HOST', 'mariadb');
$dsn = $schema . '://' . $database;
if (!empty($namespace)) {
$dsn .= '?namespace=' . $namespace;
}
$this->createAttributeFromCollection($this->dbForProject, 'databases', 'database');
$this->dbForProject->updateDocuments('databases', new Document(['database' => $dsn]));
}
}