fix: backups should be done with internal db url

fix: create default database on mongodb start with a collection
This commit is contained in:
Andras Bacsai
2023-10-24 09:34:35 +02:00
parent b539f40fa5
commit 91acd4cb6a
7 changed files with 34 additions and 11 deletions

View File

@@ -15,8 +15,16 @@ class StandaloneMongodb extends BaseModel
{
static::created(function ($database) {
LocalPersistentVolume::create([
'name' => 'mongodb-data-' . $database->uuid,
'mount_path' => '/data',
'name' => 'mongodb-configdb-' . $database->uuid,
'mount_path' => '/data/configdb',
'host_path' => null,
'resource_id' => $database->id,
'resource_type' => $database->getMorphClass(),
'is_readonly' => true
]);
LocalPersistentVolume::create([
'name' => 'mongodb-db-' . $database->uuid,
'mount_path' => '/data/db',
'host_path' => null,
'resource_id' => $database->id,
'resource_type' => $database->getMorphClass(),
@@ -55,8 +63,8 @@ class StandaloneMongodb extends BaseModel
{
return 'standalone-mongodb';
}
public function getDbUrl() {
if ($this->is_public) {
public function getDbUrl(bool $useInternal = false) {
if ($this->is_public && !$useInternal) {
return "mongodb://{$this->mongo_initdb_root_username}:{$this->mongo_initdb_root_password}@{$this->destination->server->getIp}:{$this->public_port}/?directConnection=true";
} else {
return "mongodb://{$this->mongo_initdb_root_username}:{$this->mongo_initdb_root_password}@{$this->uuid}:27017/?directConnection=true";

View File

@@ -62,9 +62,9 @@ class StandalonePostgresql extends BaseModel
{
return 'standalone-postgresql';
}
public function getDbUrl(): string
public function getDbUrl(bool $useInternal = false): string
{
if ($this->is_public) {
if ($this->is_public && !$useInternal) {
return "postgres://{$this->postgres_user}:{$this->postgres_password}@{$this->destination->server->getIp}:{$this->public_port}/{$this->postgres_db}";
} else {
return "postgres://{$this->postgres_user}:{$this->postgres_password}@{$this->uuid}:5432/{$this->postgres_db}";