Add project variable migration support#184
Conversation
Greptile SummaryThis PR introduces
Confidence Score: 5/5Safe to merge; bulk migration works correctly end-to-end. The implementation faithfully follows the established patterns for api-key and platform migration. The one observation — TYPE_PROJECT_VARIABLE missing from ROOT_RESOURCES — makes the per-variable rootResourceId filter unreachable but does not affect normal bulk migration. src/Migration/Transfer.php has the ROOT_RESOURCES gap worth a follow-up if single-variable export by ID is desired. Important Files Changed
Reviews (6): Last reviewed commit: "Merge branch 'main' into add-project-var..." | Re-trigger Greptile |
| } catch (DuplicateException) { | ||
| $resource->setStatus(Resource::STATUS_SKIPPED, 'Project variable already exists'); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| private function validateFieldsForIndexes(Index $resource, UtopiaDocument $table, array &$lengths) |
There was a problem hiding this comment.
Both
createPlatform and createApiKey call $this->dbForPlatform->purgeCachedDocument('projects', $this->project) after writing their documents. createProjectVariable omits this. If the platform's projects document caches any project-level metadata (variable counts, etc.), created variables won't be reflected until the cache naturally expires. Worth verifying against the upstream Project::Variables::Create implementation to confirm whether the purge is needed here too.
| } catch (DuplicateException) { | |
| $resource->setStatus(Resource::STATUS_SKIPPED, 'Project variable already exists'); | |
| return false; | |
| } | |
| return true; | |
| } | |
| private function validateFieldsForIndexes(Index $resource, UtopiaDocument $table, array &$lengths) | |
| } catch (DuplicateException) { | |
| $resource->setStatus(Resource::STATUS_SKIPPED, 'Project variable already exists'); | |
| return false; | |
| } | |
| $this->dbForPlatform->purgeCachedDocument('projects', $this->project); | |
| return true; | |
| } | |
| private function validateFieldsForIndexes(Index $resource, UtopiaDocument $table, array &$lengths) |
Introduces Transfer::GROUP_SETTINGS for project-level configuration resources that aren't external integrations. Project variables are the first inhabitant; webhooks will follow in a stacked PR. - New abstract Source::exportGroupSettings() with no-op stubs in CSV/JSON/Firebase/NHost sources. - Appwrite source: project variables exported via Project SDK listVariables() with cursor pagination. - Appwrite destination: createProjectVariable writes directly to dbForProject 'variables' collection, mirroring upstream Project Variables Create payload (resourceType 'project', empty resource id).
c040472 to
3376bed
Compare
- MockSource now stubs exportGroupSettings so the class is concrete (clears PHPUnit fatal + PHPStan level-3 error). - Pint ordered_imports auto-fix on Sources/Appwrite.php and Destinations/Appwrite.php.
The GROUP_SETTINGS const was added in this branch (with project-variable under it) but the extractServices() match was never updated. Any caller passing Transfer::GROUP_SETTINGS hits the 'No service group found' default branch even though GROUP_SETTINGS_RESOURCES is populated.
Summary
Stacks on #183. Adds project-variable as a migrable resource using the Appwrite SDK's
Project::listVariables()(source) and a directdbForProject->createDocument('variables', ...)(destination) that mirrors upstreamProject::Variables::Createexactly.Notes
Resource::TYPE_PROJECT_VARIABLE = 'project-variable'(kebab) — placed inGROUP_INTEGRATIONS_RESOURCESalongside platform/api-key for minimum changes to other Source/Destination implementations.resourceType: 'project'(singular, as upstream does for project-scope) with emptyresourceInternalId/resourceIdand a synthesizedsearchfield.valueon read for secret variables, so secrets will arrive with empty values. Operator re-enters them on the destination side. (Same caveat as API key secrets.)