fix: migration
This commit is contained in:
parent
4160827f92
commit
762b532674
|
@ -97,7 +97,8 @@ class V11 extends Migration
|
||||||
try {
|
try {
|
||||||
Console::log('Created internal tables for : ' . $project->getAttribute('name') . ' (' . $project->getId() . ')');
|
Console::log('Created internal tables for : ' . $project->getAttribute('name') . ' (' . $project->getId() . ')');
|
||||||
$this->dbProject->createMetadata();
|
$this->dbProject->createMetadata();
|
||||||
} catch (\Throwable $th) { }
|
} catch (\Throwable $th) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Audit tables
|
* Create Audit tables
|
||||||
|
@ -372,9 +373,10 @@ class V11 extends Migration
|
||||||
/**
|
/**
|
||||||
* Convert numeric Attributes to float.
|
* Convert numeric Attributes to float.
|
||||||
*/
|
*/
|
||||||
if (is_numeric($attr)) {
|
if (!is_string($attr) && is_numeric($attr)) {
|
||||||
$document[$key] = floatval($attr);
|
$document[$key] = floatval($attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\is_array($attr)) {
|
if (\is_array($attr)) {
|
||||||
foreach ($attr as $index => $child) {
|
foreach ($attr as $index => $child) {
|
||||||
/**
|
/**
|
||||||
|
@ -386,7 +388,7 @@ class V11 extends Migration
|
||||||
/**
|
/**
|
||||||
* Convert array of numeric Attributes to array float.
|
* Convert array of numeric Attributes to array float.
|
||||||
*/
|
*/
|
||||||
if (is_numeric($attr)) {
|
if (!is_string($child) && is_numeric($child)) {
|
||||||
$document[$key][$index] = floatval($child); // Convert any numeric to float
|
$document[$key][$index] = floatval($child); // Convert any numeric to float
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,61 +438,61 @@ 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 = [];
|
$newAuths = [];
|
||||||
$providers = Config::getParam('providers', []);
|
$providers = Config::getParam('providers', []);
|
||||||
$auths = Config::getParam('auth', []);
|
$auths = Config::getParam('auth', []);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove Tasks
|
* Remove Tasks
|
||||||
*/
|
*/
|
||||||
$document->removeAttribute('tasks');
|
$document->removeAttribute('tasks');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add enabled OAuth2 providers to default data rules
|
* Add enabled OAuth2 providers to default data rules
|
||||||
*/
|
*/
|
||||||
foreach ($providers as $index => $provider) {
|
foreach ($providers as $index => $provider) {
|
||||||
$appId = $document->getAttribute('usersOauth2'.\ucfirst($index).'Appid');
|
$appId = $document->getAttribute('usersOauth2' . \ucfirst($index) . 'Appid');
|
||||||
$appSecret = $document->getAttribute('usersOauth2'.\ucfirst($index).'Secret');
|
$appSecret = $document->getAttribute('usersOauth2' . \ucfirst($index) . 'Secret');
|
||||||
|
|
||||||
if (!is_null($appId) || !is_null($appId)) {
|
if (!is_null($appId) || !is_null($appId)) {
|
||||||
$newProviders[$appId] = $appSecret;
|
$newProviders[$appId] = $appSecret;
|
||||||
}
|
|
||||||
|
|
||||||
$document
|
|
||||||
->removeAttribute('usersOauth2'.\ucfirst($index).'Appid')
|
|
||||||
->removeAttribute('usersOauth2'.\ucfirst($index).'Secret');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$document->setAttribute('providers', $newProviders);
|
$document
|
||||||
|
->removeAttribute('usersOauth2' . \ucfirst($index) . 'Appid')
|
||||||
|
->removeAttribute('usersOauth2' . \ucfirst($index) . 'Secret');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
$document->setAttribute('providers', $newProviders);
|
||||||
|
|
||||||
|
/*
|
||||||
* Migrate User providers settings
|
* Migrate User providers settings
|
||||||
*/
|
*/
|
||||||
$oldAuths = [
|
$oldAuths = [
|
||||||
'email-password'=> 'usersAuthEmailPassword',
|
'email-password' => 'usersAuthEmailPassword',
|
||||||
'magic-url' => 'usersAuthMagicURL',
|
'magic-url' => 'usersAuthMagicURL',
|
||||||
'anonymous' => 'usersAuthAnonymous',
|
'anonymous' => 'usersAuthAnonymous',
|
||||||
'invites' => 'usersAuthInvites',
|
'invites' => 'usersAuthInvites',
|
||||||
'jwt' => 'usersAuthJWT',
|
'jwt' => 'usersAuthJWT',
|
||||||
'phone' => 'usersAuthPhone'
|
'phone' => 'usersAuthPhone'
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($oldAuths as $index => $auth) {
|
foreach ($oldAuths as $index => $auth) {
|
||||||
$enabled = $document->getAttribute($auth, true);
|
$enabled = $document->getAttribute($auth, true);
|
||||||
$newAuths['auth'.\ucfirst($auths[$index]['key'])] = $enabled;
|
$newAuths['auth' . \ucfirst($auths[$index]['key'])] = $enabled;
|
||||||
$document->removeAttribute($auth);
|
$document->removeAttribute($auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($document->getAttribute('usersAuthLimit'))) {
|
if (!empty($document->getAttribute('usersAuthLimit'))) {
|
||||||
$newAuths['limit'] = $document->getAttribute('usersAuthLimit');
|
$newAuths['limit'] = $document->getAttribute('usersAuthLimit');
|
||||||
$document->removeAttribute('usersAuthLimit');
|
$document->removeAttribute('usersAuthLimit');
|
||||||
}
|
}
|
||||||
|
|
||||||
$document->setAttribute('auths', $newProviders);
|
$document->setAttribute('auths', $newProviders);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case OldDatabase::SYSTEM_COLLECTION_PLATFORMS:
|
case OldDatabase::SYSTEM_COLLECTION_PLATFORMS:
|
||||||
$projectId = $this->getProjectIdFromReadPermissions($document);
|
$projectId = $this->getProjectIdFromReadPermissions($document);
|
||||||
|
|
||||||
|
@ -638,7 +640,6 @@ class V11 extends Migration
|
||||||
$document->setAttribute('$write', str_replace('user:{self}', "user:{$document->getId()}", $write));
|
$document->setAttribute('$write', str_replace('user:{self}', "user:{$document->getId()}", $write));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OldDatabase::SYSTEM_COLLECTION_TEAMS:
|
case OldDatabase::SYSTEM_COLLECTION_TEAMS:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue