diff --git a/src/Appwrite/Migration/Version/V23.php b/src/Appwrite/Migration/Version/V23.php index d5caf2ab3c..2e0090b3a0 100644 --- a/src/Appwrite/Migration/Version/V23.php +++ b/src/Appwrite/Migration/Version/V23.php @@ -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])); + } }