fix: Handle missing 'database' key when migrating from Appwrite Cloud#172
fix: Handle missing 'database' key when migrating from Appwrite Cloud#172vickysawant19 wants to merge 1 commit intoutopia-php:mainfrom
Conversation
Greptile SummaryAdds a Confidence Score: 5/5Safe to merge — minimal, targeted fix with correct semantics. The change is a single-line null-coalescing guard with the correct null default (consistent with how Database::fromArray() handles the same field). No P0/P1 issues remain. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "Fix: Handle missing 'database' key in Ap..." | Re-trigger Greptile |
…or correct fallback
16e5090 to
5c55df0
Compare
Summary
When migrating databases from Appwrite Cloud to a self-hosted Appwrite instance, the migration worker crashes with a PHP warning:
Warning: Undefined array key "database" in .../Migration/Sources/Appwrite.php on line 868Root Cause
In
exportDatabases(), the code builds a database object using the raw API response from Appwrite Cloud:Newer versions of the Appwrite Cloud API do not return the internal
databasekey in the database listing response. This causes a fatal PHP warning that halts the migration.Fix
Updated the logic to use
nullinstead of an empty string''for thedatabasefield when it's missing from the source. This is crucial because:''causes Appwrite 1.9.0 to attempt parsing an invalid DSN (e.g.,mysql://), leading to HTTP 500 errors.nullallows Appwrite's internalgetAttribute()logic to correctly trigger the default fallback to the internal connection pool (e.g.,database_db_main).Testing
Tested successfully by performing a full Cloud to self-hosted migration:
1 database migrated
15 tables migrated
141 columns migrated
11,791 rows migrated