Skip to content

Commit 8a0ebdb

Browse files
committed
docs: clarify resolver scope — when source/destination DSNs differ
"Cross-instance migrations" was ambiguous: it read like cloud-to-cloud or dedicated-DB migration. The actual scope is narrower — any case where the source project's stored DSN doesn't apply to the destination project (cross-host within the same instance, cross-region, mixed shared-tables migration). Reword the property, constructor, and inline write-site comments to say that explicitly.
1 parent ff3b444 commit 8a0ebdb

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

src/Migration/Destinations/Appwrite.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ class Appwrite extends Destination
104104
protected $getDatabasesDB;
105105

106106
/**
107-
* Resolves the DSN written into the destination's `_databases.database` for
108-
* a migrated database. When unset, the attribute is left blank and the
109-
* runtime falls back to the destination project's DSN — correct for legacy
110-
* single-DSN projects, but cross-instance / multi-type setups must inject
111-
* a resolver so source DSNs don't bleed into the destination metadata.
107+
* Resolves the DSN written into the destination's `_databases.database`
108+
* for a migrated database. When the source and destination projects don't
109+
* share the same DSN — e.g. one project is on a host the other isn't —
110+
* pass a resolver so the destination metadata carries its own DSN instead
111+
* of the source's. When unset, the attribute is left blank and the
112+
* runtime falls back to the destination project's DSN at read time, which
113+
* is safe for single-host single-type setups.
112114
*
113115
* @var (callable(Database $resource): string)|null
114116
*/
@@ -150,7 +152,7 @@ class Appwrite extends Destination
150152
* @param callable(UtopiaDocument $database):UtopiaDatabase $getDatabasesDB
151153
* @param array<array<string, mixed>> $collectionStructure
152154
* @param OnDuplicate $onDuplicate Behavior when a row with an existing $id is encountered.
153-
* @param (callable(Database $resource): string)|null $getDatabaseDSN Resolver for the destination's `_databases.database` value. Required for cross-instance migrations to prevent the source DSN from being written into the destination project's metadata.
155+
* @param (callable(Database $resource): string)|null $getDatabaseDSN Resolver for the destination's `_databases.database` value. Pass when the destination project's DSN differs from the source's, so the destination row carries its own DSN instead of inheriting the source's.
154156
*/
155157
public function __construct(
156158
string $project,
@@ -185,8 +187,9 @@ public function __construct(
185187
/**
186188
* Resolve the DSN written into the destination's `_databases.database`.
187189
* Without a resolver, leave it blank — the source DSN must never be
188-
* propagated, since cross-instance source/destination DSNs differ and
189-
* propagation routes destination reads to the wrong host (see PR #151).
190+
* propagated as the default, since when source and destination DSNs
191+
* differ propagation routes destination reads to the wrong host (the
192+
* regression PR #151 introduced).
190193
*/
191194
private function resolveDestinationDsn(Database $resource): string
192195
{
@@ -569,7 +572,7 @@ protected function createDatabase(Database $resource): bool
569572
'$updatedAt' => $updatedAt,
570573
'originalId' => empty($resource->getOriginalId()) ? null : $resource->getOriginalId(),
571574
'type' => empty($resource->getType()) ? 'legacy' : $resource->getType(),
572-
// Source and destination can be in different locations; never write the source DSN here.
575+
// Resolved by the destination's resolver (or left blank); never copy the source's DSN by default.
573576
'database' => $this->resolveDestinationDsn($resource),
574577
]));
575578

0 commit comments

Comments
 (0)