Rename reason to errors

This commit is contained in:
Bradley Schofield
2023-07-17 15:17:06 +01:00
parent 94fe4f7189
commit 88b59295d1
11 changed files with 36 additions and 25 deletions
+3 -3
View File
@@ -3639,7 +3639,7 @@ $collections = [
'required' => true,
'default' => null,
'array' => false,
'filters' => [],
'filters' => ['json'],
],
[
'$id' => ID::custom('resourceData'),
@@ -3653,14 +3653,14 @@ $collections = [
'filters' => ['json'],
],
[
'$id' => ID::custom('reason'),
'$id' => ID::custom('errors'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 65535,
'signed' => true,
'required' => true,
'default' => null,
'array' => false,
'array' => true,
'filters' => [],
],
[
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4 -4
View File
@@ -216,7 +216,7 @@ App::post('/v1/migrations/appwrite')
'resources' => $resources,
'statusCounters' => '{}',
'resourceData' => "{}",
'reason' => ''
'errors' => []
]));
$eventsInstance->setParam('migrationId', $migration->getId());
@@ -295,7 +295,7 @@ App::post('/v1/migrations/firebase')
'resources' => $resources,
'statusCounters' => '{}',
'resourceData' => "{}",
'reason' => ''
'errors' => []
]));
$eventsInstance->setParam('migrationId', $migration->getId());
@@ -385,7 +385,7 @@ App::post('/v1/migrations/supabase')
'resources' => $resources,
'statusCounters' => '{}',
'resourceData' => "{}",
'reason' => ''
'errors' => []
]));
$eventsInstance->setParam('migrationId', $migration->getId());
@@ -490,7 +490,7 @@ App::post('/v1/migrations/nhost')
'resources' => $resources,
'statusCounters' => '{}',
'resourceData' => "{}",
'reason' => ''
'errors' => []
]));
$eventsInstance->setParam('migrationId', $migration->getId());
+10 -5
View File
@@ -218,6 +218,7 @@ class MigrationsV1 extends Worker
try {
$migrationDocument = $this->dbForProject->getDocument('migrations', $this->args['migration']['$id']);
$migrationDocument->setAttribute('stage', 'processing');
$migrationDocument->setAttribute('status', 'processing');
$this->updateMigrationDocument($migrationDocument, $projectDocument);
$source = $this->processSource(json_decode($migrationDocument->getAttribute('source'), true));
@@ -252,10 +253,15 @@ class MigrationsV1 extends Worker
$errors = $transfer->getReport(Resource::STATUS_ERROR);
if (count($errors) > 0) {
var_dump($errors);
$migrationDocument->setAttribute('status', 'failed');
$migrationDocument->setAttribute('stage', 'finished');
$migrationDocument->setAttribute('reason', $errors[0]['message']);
$errorMessages = [];
foreach ($errors as $error) {
$errorMessages[] = "Failed to transfer resource '{$error['id']}:{$error['resource']}' with message '{$error['message']}'";
}
$migrationDocument->setAttribute('errors', $errorMessages);
$this->updateMigrationDocument($migrationDocument, $projectDocument);
return;
}
@@ -270,7 +276,7 @@ class MigrationsV1 extends Worker
Console::error($th->getTraceAsString());
$migrationDocument->setAttribute('status', 'failed');
$migrationDocument->setAttribute('stage', 'finished');
$migrationDocument->setAttribute('reason', $th->getMessage());
$migrationDocument->setAttribute('errors', [$th->getMessage()]);
return;
}
@@ -278,10 +284,9 @@ class MigrationsV1 extends Worker
$errors = $transfer->getReport(Resource::STATUS_ERROR);
if (count($errors) > 0) {
var_dump($errors);
$migrationDocument->setAttribute('status', 'failed');
$migrationDocument->setAttribute('stage', 'finished');
$migrationDocument->setAttribute('reason', $errors[0]['message']);
$migrationDocument->setAttribute('errors', $errors);
}
}
} finally {
Generated
+4 -4
View File
@@ -2942,12 +2942,12 @@
"source": {
"type": "git",
"url": "https://github.com/utopia-php/transfer.git",
"reference": "e19cf3734af195e000211c50e7eae7fec1d89e97"
"reference": "d22c31a6fe5dd4fa51b1d487bff3f6f438269bc3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/transfer/zipball/e19cf3734af195e000211c50e7eae7fec1d89e97",
"reference": "e19cf3734af195e000211c50e7eae7fec1d89e97",
"url": "https://api.github.com/repos/utopia-php/transfer/zipball/d22c31a6fe5dd4fa51b1d487bff3f6f438269bc3",
"reference": "d22c31a6fe5dd4fa51b1d487bff3f6f438269bc3",
"shasum": ""
},
"require": {
@@ -2996,7 +2996,7 @@
"source": "https://github.com/utopia-php/transfer/tree/feat-improve-features",
"issues": "https://github.com/utopia-php/transfer/issues"
},
"time": "2023-07-12T10:35:19+00:00"
"time": "2023-07-17T12:37:12+00:00"
},
{
"name": "utopia-php/websocket",
@@ -11,7 +11,7 @@ class Migrations extends Base
'resources',
'statusCounters',
'resourceData',
'reason'
'errors'
];
/**
@@ -65,11 +65,11 @@ class Migration extends Model
'default' => [],
'example' => '[{"resource":"Database","id":"public","status":"SUCCESS","message":""}]',
])
->addRule('reason', [
->addRule('errors', [
'type' => self::TYPE_STRING,
'description' => 'The reason for a migration failure if any.',
'default' => '',
'example' => '',
'description' => 'All errors that occurred during the migration process.',
'default' => [],
'example' => [],
])
;
}
@@ -58,6 +58,12 @@ class MigrationReport extends Model
'description' => 'Size of files to be migrated in mb.',
'default' => 0,
'example' => 30000,
])
->addRule('version', [
'type' => self::TYPE_STRING,
'description' => 'Version of the Appwrite instance to be migrated.',
'default' => '',
'example' => '1.4.0',
]);
}