mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
added patch script for adding database dsn in the databases collection
This commit is contained in:
@@ -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]));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user