diff --git a/composer.lock b/composer.lock index 9dbcd5c5ec..9d4300f0a4 100644 --- a/composer.lock +++ b/composer.lock @@ -2005,16 +2005,16 @@ }, { "name": "utopia-php/migration", - "version": "0.4.0", + "version": "0.4.1", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "a72f27bd3dde68752fb185d306c4820e1b8d9657" + "reference": "ae3cfe93f6d313105d226aeb68806660c806a925" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/a72f27bd3dde68752fb185d306c4820e1b8d9657", - "reference": "a72f27bd3dde68752fb185d306c4820e1b8d9657", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/ae3cfe93f6d313105d226aeb68806660c806a925", + "reference": "ae3cfe93f6d313105d226aeb68806660c806a925", "shasum": "" }, "require": { @@ -2047,9 +2047,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.4.0" + "source": "https://github.com/utopia-php/migration/tree/0.4.1" }, - "time": "2024-02-25T12:35:21+00:00" + "time": "2024-05-01T13:19:18+00:00" }, { "name": "utopia-php/mongo", @@ -2991,16 +2991,16 @@ }, { "name": "laravel/pint", - "version": "v1.15.2", + "version": "v1.15.3", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "2c9f8004899815f3f0ee3cb28ef7281e2b589134" + "reference": "3600b5d17aff52f6100ea4921849deacbbeb8656" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/2c9f8004899815f3f0ee3cb28ef7281e2b589134", - "reference": "2c9f8004899815f3f0ee3cb28ef7281e2b589134", + "url": "https://api.github.com/repos/laravel/pint/zipball/3600b5d17aff52f6100ea4921849deacbbeb8656", + "reference": "3600b5d17aff52f6100ea4921849deacbbeb8656", "shasum": "" }, "require": { @@ -3053,7 +3053,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-04-23T15:42:34+00:00" + "time": "2024-04-30T15:02:26+00:00" }, { "name": "matthiasmullie/minify", diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 7bbfcfbce2..8e4aa5216d 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -16,6 +16,7 @@ use Utopia\Database\Exception\Restricted; use Utopia\Database\Exception\Structure; use Utopia\Database\Helpers\ID; use Utopia\Logger\Log; +use Utopia\Logger\Log\Breadcrumb; use Utopia\Migration\Destinations\Appwrite as DestinationsAppwrite; use Utopia\Migration\Exception as MigrationException; use Utopia\Migration\Source; @@ -85,6 +86,7 @@ class Migrations extends Action return; } + $log->addTag('migrationId', $migration->getId()); $log->addTag('projectId', $project->getId()); $this->processMigration($project, $migration, $log); @@ -256,6 +258,7 @@ class Migrations extends Action $migrationDocument = $this->dbForProject->getDocument('migrations', $migration->getId()); $migrationDocument->setAttribute('stage', 'processing'); $migrationDocument->setAttribute('status', 'processing'); + $log->addBreadcrumb(new Breadcrumb("debug", "migration", "Migration hit stage 'processing'", \microtime(true))); $this->updateMigrationDocument($migrationDocument, $projectDocument); $log->addTag('type', $migrationDocument->getAttribute('source')); @@ -277,6 +280,7 @@ class Migrations extends Action /** Start Transfer */ $migrationDocument->setAttribute('stage', 'migrating'); + $log->addBreadcrumb(new Breadcrumb("debug", "migration", "Migration hit stage 'migrating'", \microtime(true))); $this->updateMigrationDocument($migrationDocument, $projectDocument); $transfer->run($migrationDocument->getAttribute('resources'), function () use ($migrationDocument, $transfer, $projectDocument) { $migrationDocument->setAttribute('resourceData', json_encode($transfer->getCache())); @@ -291,6 +295,7 @@ class Migrations extends Action if (!empty($sourceErrors) || !empty($destinationErrors)) { $migrationDocument->setAttribute('status', 'failed'); $migrationDocument->setAttribute('stage', 'finished'); + $log->addBreadcrumb(new Breadcrumb("debug", "migration", "Migration hit stage 'finished' and failed", \microtime(true))); $errorMessages = []; foreach ($sourceErrors as $error) { @@ -303,6 +308,7 @@ class Migrations extends Action } $migrationDocument->setAttribute('errors', $errorMessages); + $log->addExtra('migrationErrors', json_encode($errorMessages)); $this->updateMigrationDocument($migrationDocument, $projectDocument); return; @@ -310,6 +316,7 @@ class Migrations extends Action $migrationDocument->setAttribute('status', 'completed'); $migrationDocument->setAttribute('stage', 'finished'); + $log->addBreadcrumb(new Breadcrumb("debug", "migration", "Migration hit stage 'finished' and succeeded", \microtime(true))); } catch (\Throwable $th) { Console::error($th->getMessage()); @@ -338,6 +345,7 @@ class Migrations extends Action } $migrationDocument->setAttribute('errors', $errorMessages); + $log->addTag('migrationErrors', json_encode($errorMessages)); } } finally { if ($tempAPIKey) { @@ -347,7 +355,7 @@ class Migrations extends Action $this->updateMigrationDocument($migrationDocument, $projectDocument); if ($migrationDocument->getAttribute('status', '') == 'failed') { - throw new Exception(implode("\n", $migrationDocument->getAttribute('errors', []))); + throw new Exception("Migration failed"); } } }