mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Fixed PSR issues in Migration library
Signed-off-by: waridrox <mohdwarid4@gmail.com>
This commit is contained in:
parent
6b20537fbd
commit
db7e1f5ebb
2 changed files with 14 additions and 18 deletions
|
|
@ -52,7 +52,7 @@ abstract class Migration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migration constructor.
|
* Migration constructor.
|
||||||
*
|
*
|
||||||
* @param PDO $pdo
|
* @param PDO $pdo
|
||||||
*/
|
*/
|
||||||
public function __construct(PDO $db)
|
public function __construct(PDO $db)
|
||||||
|
|
@ -62,11 +62,11 @@ abstract class Migration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set project for migration.
|
* Set project for migration.
|
||||||
*
|
*
|
||||||
* @param Document $project
|
* @param Document $project
|
||||||
* @param Database $projectDB
|
* @param Database $projectDB
|
||||||
*
|
*
|
||||||
* @return Migration
|
* @return Migration
|
||||||
*/
|
*/
|
||||||
public function setProject(Document $project, Database $projectDB): Migration
|
public function setProject(Document $project, Database $projectDB): Migration
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +78,7 @@ abstract class Migration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates through every document.
|
* Iterates through every document.
|
||||||
*
|
*
|
||||||
* @param callable $callback
|
* @param callable $callback
|
||||||
*/
|
*/
|
||||||
public function forEachDocument(callable $callback): void
|
public function forEachDocument(callable $callback): void
|
||||||
|
|
@ -98,7 +98,6 @@ abstract class Migration
|
||||||
|
|
||||||
Console::log('Migrating: ' . $offset . ' / ' . $this->projectDB->getSum());
|
Console::log('Migrating: ' . $offset . ' / ' . $this->projectDB->getSum());
|
||||||
\Co\run(function () use ($all, $callback) {
|
\Co\run(function () use ($all, $callback) {
|
||||||
|
|
||||||
foreach ($all as $document) {
|
foreach ($all as $document) {
|
||||||
go(function () use ($document, $callback) {
|
go(function () use ($document, $callback) {
|
||||||
if (empty($document->getId()) || empty($document->getCollection())) {
|
if (empty($document->getId()) || empty($document->getCollection())) {
|
||||||
|
|
@ -131,24 +130,23 @@ abstract class Migration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function check_diff_multi($array1, $array2){
|
public function check_diff_multi($array1, $array2)
|
||||||
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
foreach($array1 as $key => $val) {
|
foreach ($array1 as $key => $val) {
|
||||||
if(is_array($val) && isset($array2[$key])) {
|
if (is_array($val) && isset($array2[$key])) {
|
||||||
$tmp = $this->check_diff_multi($val, $array2[$key]);
|
$tmp = $this->check_diff_multi($val, $array2[$key]);
|
||||||
if($tmp) {
|
if ($tmp) {
|
||||||
$result[$key] = $tmp;
|
$result[$key] = $tmp;
|
||||||
}
|
}
|
||||||
}
|
} elseif (!isset($array2[$key])) {
|
||||||
elseif(!isset($array2[$key])) {
|
|
||||||
$result[$key] = null;
|
$result[$key] = null;
|
||||||
}
|
} elseif ($val !== $array2[$key]) {
|
||||||
elseif($val !== $array2[$key]) {
|
|
||||||
$result[$key] = $array2[$key];
|
$result[$key] = $array2[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($array2[$key])) {
|
if (isset($array2[$key])) {
|
||||||
unset($array2[$key]);
|
unset($array2[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Appwrite\Migration\Version;
|
namespace Appwrite\Migration\Version;
|
||||||
|
|
||||||
|
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
use Utopia\CLI\Console;
|
use Utopia\CLI\Console;
|
||||||
use Appwrite\Database\Database;
|
use Appwrite\Database\Database;
|
||||||
|
|
@ -35,8 +34,7 @@ class V06 extends Migration
|
||||||
case Database::SYSTEM_COLLECTION_KEYS:
|
case Database::SYSTEM_COLLECTION_KEYS:
|
||||||
if ($document->getAttribute('secret', null)) {
|
if ($document->getAttribute('secret', null)) {
|
||||||
$json = \json_decode($document->getAttribute('secret'), true);
|
$json = \json_decode($document->getAttribute('secret'), true);
|
||||||
if (is_array($json))
|
if (is_array($json)) {
|
||||||
{
|
|
||||||
Console::log('Secret already encrypted. Skipped: ' . $document->getId());
|
Console::log('Secret already encrypted. Skipped: ' . $document->getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue