1
0
Fork 0
mirror of synced 2024-10-02 02:07:04 +13:00

Merge pull request #6851 from appwrite/feat-sm-db

update projects database
This commit is contained in:
Christy Jacob 2023-10-22 22:35:54 +04:00 committed by GitHub
commit bb46e3869c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View file

@ -92,15 +92,16 @@ App::post('/v1/projects')
$projectId = ($projectId == 'unique()') ? ID::unique() : $projectId;
$backups['database_db_fra1_v14x_02'] = ['from' => '03:00', 'to' => '04:00'];
$backups['database_db_fra1_v14x_03'] = ['from' => '00:00', 'to' => '01:00'];
$backups['database_db_fra1_v14x_04'] = ['from' => '00:00', 'to' => '01:00'];
$backups['database_db_fra1_v14x_05'] = ['from' => '00:00', 'to' => '01:00'];
$backups['database_db_fra1_v14x_06'] = ['from' => '00:00', 'to' => '01:00'];
$backups['database_db_fra1_v14x_07'] = ['from' => '00:00', 'to' => '01:00'];
$backups['database_db_fra1_v14x_02'] = ['from' => '03:00', 'to' => '05:00'];
$backups['database_db_fra1_v14x_03'] = ['from' => '00:00', 'to' => '02:00'];
$backups['database_db_fra1_v14x_04'] = ['from' => '00:00', 'to' => '02:00'];
$backups['database_db_fra1_v14x_05'] = ['from' => '00:00', 'to' => '02:00'];
$backups['database_db_fra1_v14x_06'] = ['from' => '00:00', 'to' => '02:00'];
$backups['database_db_fra1_v14x_07'] = ['from' => '00:00', 'to' => '02:00'];
$databases = Config::getParam('pools-database', []);
/**
* Remove databases from the list that are currently undergoing an backup
*/
@ -170,6 +171,15 @@ App::post('/v1/projects')
throw new Exception(Exception::PROJECT_ALREADY_EXISTS);
}
/**
* Update database with self-managed db every $mod projects
*/
$mod = 20;
if ($index = array_search('database_db_fra1_self_hosted_0_0', $databases) && $project->getInternalId() % $mod === 0) {
$project->setAttribute('database', $databases[$index]);
$dbForConsole->updateDocument('projects', $project);
}
$dbForProject = new Database($pools->get($database)->pop()->getResource(), $cache);
$dbForProject->setNamespace("_{$project->getInternalId()}");
$dbForProject->create();

2
composer.lock generated
View file

@ -5889,5 +5889,5 @@
"platform-overrides": {
"php": "8.0"
},
"plugin-api-version": "2.6.0"
"plugin-api-version": "2.2.0"
}