mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Rename SDK-boundary constants to IMMUTABLE_FIELDS; fix META doc
Maintainer review feedback: - ATTRIBUTE_NON_SDK_FIELDS -> ATTRIBUTE_IMMUTABLE_FIELDS - RELATIONSHIP_STRUCTURAL_FIELDS -> RELATIONSHIP_IMMUTABLE_FIELDS - META_* docblock 'platform-DB' -> 'project-DB' (these collections live in dbForProject, not the platform-level DB) Naming shift: "NON_SDK"/"STRUCTURAL" describes the cause (SDK doesn't expose them), "IMMUTABLE" describes the effect (can't change in place, only via drop+recreate). The latter is the audience-facing semantic. SDK-boundary lock-in test (AppwriteAttributeSdkBoundaryTest) still reflects on the renamed constant; updated its references.
This commit is contained in:
1 parent
7d71505ec0
commit
5520cb2585
2 files changed
+14
-14
No files matched your search
@@ -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<string, mixed> $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;
|
||||
}
|
||||
|
||||
@@ -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<string> $value */
|
||||
$value = (new ReflectionClass(AppwriteDestination::class))->getConstant('ATTRIBUTE_NON_SDK_FIELDS');
|
||||
$value = (new ReflectionClass(AppwriteDestination::class))->getConstant('ATTRIBUTE_IMMUTABLE_FIELDS');
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user