fix: migration

This commit is contained in:
Torsten Dittmann 2022-01-04 18:27:19 +01:00
parent f397f93975
commit 3e4e5a787d

View file

@ -175,6 +175,7 @@ class V11 extends Migration
'$collection!=' . OldDatabase::SYSTEM_COLLECTION_TASKS, '$collection!=' . OldDatabase::SYSTEM_COLLECTION_TASKS,
'$collection!=' . OldDatabase::SYSTEM_COLLECTION_PROJECTS, '$collection!=' . OldDatabase::SYSTEM_COLLECTION_PROJECTS,
'$collection!=' . OldDatabase::SYSTEM_COLLECTION_CONNECTIONS, '$collection!=' . OldDatabase::SYSTEM_COLLECTION_CONNECTIONS,
'$collection!=' . OldDatabase::SYSTEM_COLLECTION_RESERVED,
] ]
]); ]);
@ -421,7 +422,7 @@ class V11 extends Migration
* Check attributes and set their default values. * Check attributes and set their default values.
*/ */
if (array_key_exists($document->getCollection(), $this->oldCollections)) { if (array_key_exists($document->getCollection(), $this->oldCollections)) {
foreach ($this->newCollections[$document->getCollection()]['attributes'] as $attr) { foreach ($this->newCollections[$document->getCollection()]['attributes'] ?? [] as $attr) {
if ( if (
(!$attr['array'] || (!$attr['array'] ||
($attr['array'] && array_key_exists('filter', $attr) ($attr['array'] && array_key_exists('filter', $attr)
@ -436,7 +437,9 @@ class V11 extends Migration
switch ($document->getAttribute('$collection')) { switch ($document->getAttribute('$collection')) {
case OldDatabase::SYSTEM_COLLECTION_PROJECTS: case OldDatabase::SYSTEM_COLLECTION_PROJECTS:
$newProviders = []; $newProviders = [];
$newAuths = [];
$providers = Config::getParam('providers', []); $providers = Config::getParam('providers', []);
$auths = Config::getParam('auth', []);
/* /*
* Add enabled OAuth2 providers to default data rules * Add enabled OAuth2 providers to default data rules
@ -456,6 +459,22 @@ class V11 extends Migration
$document->setAttribute('providers', $newProviders); $document->setAttribute('providers', $newProviders);
/*
* Migrate User providers settings
*/
foreach ($auths as $index => $auth) {
$enabled = $document->getAttribute('auth'.\ucfirst($auth['key']), true);
$newAuths['auth'.\ucfirst($auth['key'])] = $enabled;
$document->removeAttribute('auth'.\ucfirst($auth['key']));
}
if (!empty($document->getAttribute('usersAuthLimit'))) {
$newAuths['limit'] = $document->getAttribute('usersAuthLimit');
$document->removeAttribute('usersAuthLimit');
}
$document->setAttribute('auths', $newProviders);
break; break;
case OldDatabase::SYSTEM_COLLECTION_PLATFORMS: case OldDatabase::SYSTEM_COLLECTION_PLATFORMS:
$projectId = $this->getProjectIdFromReadPermissions($document); $projectId = $this->getProjectIdFromReadPermissions($document);