Add project variable migration support#184
Conversation
Source: Appwrite SDK Project::listVariables() with cursor pagination,
counting via reportIntegrations.
Destination: dbForProject->createDocument('variables', ...) matching
the upstream Project::Variables::Create payload exactly — resourceType
'project' (singular), resourceInternalId/resourceId empty, plus the
search index field.
Greptile SummaryThis PR adds
Confidence Score: 4/5Safe to merge; the only open question is whether a platform project-cache purge is needed after writing to dbForProject. The implementation faithfully mirrors the ApiKey/Platform patterns. The one thing that stands out is that src/Migration/Destinations/Appwrite.php — the Important Files Changed
Reviews (1): Last reviewed commit: "Add project variable migration support" | 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) |
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.)