From 5cd149eafead7a7d4f0ec9eb4fe6098307449ed0 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Fri, 16 Jun 2023 19:20:52 +0100 Subject: [PATCH] Continue work on migrations --- Dockerfile | 4 ++-- app/workers/migrations.php | 35 ++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9faaa15b74..ccc6c89a41 100755 --- a/Dockerfile +++ b/Dockerfile @@ -29,12 +29,12 @@ ENV VITE_APPWRITE_GROWTH_ENDPOINT=$VITE_APPWRITE_GROWTH_ENDPOINT RUN npm ci RUN npm run build -FROM appwrite/base:0.2.2 as final +FROM ionic/base as final LABEL maintainer="team@appwrite.io" ARG VERSION=dev -ARG DEBUG=false +ARG DEBUG=true ENV DEBUG=$DEBUG ENV DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} diff --git a/app/workers/migrations.php b/app/workers/migrations.php index 0620723252..e2e41f9fb9 100644 --- a/app/workers/migrations.php +++ b/app/workers/migrations.php @@ -46,6 +46,24 @@ class MigrationsV1 extends Worker public function run(): void { + $type = $this->args['type'] ?? ''; + $events = $this->args['events'] ?? []; + $project = new Document($this->args['project'] ?? []); + $user = new Document($this->args['user'] ?? []); + $payload = json_encode($this->args['payload'] ?? []); + + if ($project->getId() === 'console') { + return; + } + + + /** + * Handle Event execution. + */ + if (!empty($events)) { + return; + } + $this->dbForProject = $this->getProjectDB($this->args['project']['$id']); // Process @@ -69,9 +87,9 @@ class MigrationsV1 extends Worker case 'supabase': return new Supabase( $source['endpoint'], - $source['key'], - $source['host'], - $source['database'], + $source['apiKey'], + $source['databaseHost'], + "postgres", $source['username'], $source['password'], $source['port'], @@ -155,25 +173,21 @@ class MigrationsV1 extends Worker 'projectId' => $project->getId(), 'name' => 'Transfer API Key', 'scopes' => [ - // Auth 'users.read', 'users.write', 'teams.read', 'teams.write', - // Database 'databases.read', 'databases.write', 'collections.read', 'collections.write', 'documents.read', 'documents.write', - // Storage 'buckets.read', 'buckets.write', 'files.read', 'files.write', - // Functions 'functions.read', 'functions.write', ], @@ -183,7 +197,10 @@ class MigrationsV1 extends Worker 'secret' => $generatedSecret, ]); - return $consoleDB->createDocument('keys', $key); + $consoleDB->createDocument('keys', $key); + $consoleDB->deleteCachedDocument('projects', $project->getId()); + + return $key; } /** @@ -199,7 +216,7 @@ class MigrationsV1 extends Worker */ $migrationDocument = null; $transfer = null; - $projectDocument = $this->dbForProject->getDocument('projects', $this->args['project']['$id']); + $projectDocument = $this->getConsoleDB()->getDocument('projects', $this->args['project']['$id']); $tempAPIKey = $this->generateAPIKey($projectDocument); try {