@@ -59,9 +59,14 @@ class Appwrite extends Destination
5959
6060 /**
6161 * @var callable(UtopiaDocument $database): UtopiaDatabase
62- */
62+ */
6363 protected mixed $ getDatabasesDB ;
6464
65+ /**
66+ * @var callable(string $databaseType):string
67+ */
68+ protected mixed $ getDatabaseDSN ;
69+
6570 /**
6671 * @var array<UtopiaDocument>
6772 */
@@ -73,6 +78,7 @@ class Appwrite extends Destination
7378 * @param string $key
7479 * @param UtopiaDatabase $dbForProject
7580 * @param callable(UtopiaDocument $database):UtopiaDatabase $getDatabasesDB
81+ * @param callable(string $databaseType):string $getDatabaseDSN
7682 * @param array<array<string, mixed>> $collectionStructure
7783 */
7884 public function __construct (
@@ -81,6 +87,7 @@ public function __construct(
8187 string $ key ,
8288 protected UtopiaDatabase $ dbForProject ,
8389 callable $ getDatabasesDB ,
90+ callable $ getDatabasesDSN ,
8491 protected array $ collectionStructure
8592 ) {
8693 $ this ->project = $ project ;
@@ -98,6 +105,7 @@ public function __construct(
98105 $ this ->users = new Users ($ this ->client );
99106
100107 $ this ->getDatabasesDB = $ getDatabasesDB ;
108+ $ this ->getDatabaseDSN = $ getDatabasesDSN ;
101109 }
102110
103111 public static function getName (): string
@@ -349,7 +357,8 @@ protected function createDatabase(Database $resource): bool
349357 '$updatedAt ' => $ resource ->getUpdatedAt (),
350358 'originalId ' => empty ($ resource ->getOriginalId ()) ? null : $ resource ->getOriginalId (),
351359 'type ' => empty ($ resource ->getType ()) ? 'legacy ' : $ resource ->getType (),
352- 'database ' => $ resource ->getDatabase ()
360+ // source and destination can be in different location
361+ 'database ' => call_user_func ($ this ->getDatabaseDSN , $ resource ->getType ())
353362 ]));
354363
355364 $ resource ->setSequence ($ database ->getSequence ());
0 commit comments