diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index a9254e57fa..ca0b9cd30b 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -63,13 +63,13 @@ use Utopia\Migration\Transfer; class Appwrite extends Destination { - /** Names of the platform-DB collections holding Appwrite schema metadata. */ + /** Names of the project-DB collections holding Appwrite schema metadata. */ private const META_DATABASES = 'databases'; private const META_ATTRIBUTES = 'attributes'; private const META_INDEXES = 'indexes'; - /** Fields the SDK's per-type updateXAttribute endpoints don't expose; a change here forces drop+recreate. */ - private const ATTRIBUTE_NON_SDK_FIELDS = [ + /** Attribute fields the SDK can't update in place (no per-type updateX endpoint exposes them); a change here forces drop+recreate. */ + private const ATTRIBUTE_IMMUTABLE_FIELDS = [ 'type', 'array', 'signed', @@ -78,8 +78,8 @@ class Appwrite extends Destination 'filters', ]; - /** Fields the SDK's updateRelationshipAttribute doesn't expose (only onDelete/newKey are SDK-reachable). */ - private const RELATIONSHIP_STRUCTURAL_FIELDS = [ + /** Relationship options fields the SDK can't update in place (only onDelete/newKey are SDK-reachable); a change here forces drop+recreate. */ + private const RELATIONSHIP_IMMUTABLE_FIELDS = [ 'relationType', 'twoWay', 'twoWayKey', @@ -1384,11 +1384,11 @@ class Appwrite extends Destination ]; $existingFields = []; - foreach (self::ATTRIBUTE_NON_SDK_FIELDS as $field) { + foreach (self::ATTRIBUTE_IMMUTABLE_FIELDS as $field) { $existingFields[$field] = $existingAttr->getAttribute($field); } - if ($this->arraysDifferOnKeys($sourceFields, $existingFields, self::ATTRIBUTE_NON_SDK_FIELDS)) { + if ($this->arraysDifferOnKeys($sourceFields, $existingFields, self::ATTRIBUTE_IMMUTABLE_FIELDS)) { return false; } @@ -1441,7 +1441,7 @@ class Appwrite extends Destination $sourceOptions = $resource->getOptions(); $destOptions = $existingAttr->getAttribute('options', []); - if ($this->arraysDifferOnKeys($sourceOptions, $destOptions, self::RELATIONSHIP_STRUCTURAL_FIELDS)) { + if ($this->arraysDifferOnKeys($sourceOptions, $destOptions, self::RELATIONSHIP_IMMUTABLE_FIELDS)) { return false; } @@ -1548,7 +1548,7 @@ class Appwrite extends Destination $sourceOptions = $resource->getOptions(); /** @var array $destOptions */ $destOptions = $existing->getAttribute('options', []); - foreach (self::RELATIONSHIP_STRUCTURAL_FIELDS as $field) { + foreach (self::RELATIONSHIP_IMMUTABLE_FIELDS as $field) { if (!$this->valuesMatch($sourceOptions[$field] ?? null, $destOptions[$field] ?? null)) { return false; } diff --git a/tests/Migration/Unit/Destinations/AppwriteAttributeSdkBoundaryTest.php b/tests/Migration/Unit/Destinations/AppwriteAttributeSdkBoundaryTest.php index 3b2fdddc33..a079ea61fb 100644 --- a/tests/Migration/Unit/Destinations/AppwriteAttributeSdkBoundaryTest.php +++ b/tests/Migration/Unit/Destinations/AppwriteAttributeSdkBoundaryTest.php @@ -10,12 +10,12 @@ use ReflectionMethod; use Utopia\Migration\Destinations\Appwrite as AppwriteDestination; /** - * Lock-in for the SDK boundary that drives ATTRIBUTE_NON_SDK_FIELDS. + * Lock-in for the SDK boundary that drives ATTRIBUTE_IMMUTABLE_FIELDS. * * Reflects on appwrite/appwrite's TablesDB + Databases services. If the SDK * ships a new updateXColumn / updateXAttribute endpoint that exposes a * previously-non-SDK field, this test fails so DestinationAppwrite's - * ATTRIBUTE_NON_SDK_FIELDS constant can be synced. Catches drift in CI + * ATTRIBUTE_IMMUTABLE_FIELDS constant can be synced. Catches drift in CI * rather than at runtime. */ class AppwriteAttributeSdkBoundaryTest extends TestCase @@ -47,9 +47,9 @@ class AppwriteAttributeSdkBoundaryTest extends TestCase $this->assertSame( [], \array_values($overlap), - 'ATTRIBUTE_NON_SDK_FIELDS marks these fields as non-SDK, but the appwrite/appwrite ' + 'ATTRIBUTE_IMMUTABLE_FIELDS marks these fields as non-SDK, but the appwrite/appwrite ' . 'SDK exposes them via updateXColumn/updateXAttribute: ' . \implode(', ', $overlap) - . '. Either drop these from ATTRIBUTE_NON_SDK_FIELDS or update PARAM_TO_META_FIELD ' + . '. Either drop these from ATTRIBUTE_IMMUTABLE_FIELDS or update PARAM_TO_META_FIELD ' . 'in this test if the SDK param doesn\'t correspond to a top-level meta-doc field.', ); } @@ -90,7 +90,7 @@ class AppwriteAttributeSdkBoundaryTest extends TestCase private function readNonSdkConstant(): array { /** @var list $value */ - $value = (new ReflectionClass(AppwriteDestination::class))->getConstant('ATTRIBUTE_NON_SDK_FIELDS'); + $value = (new ReflectionClass(AppwriteDestination::class))->getConstant('ATTRIBUTE_IMMUTABLE_FIELDS'); return $value; } }