@@ -118,6 +118,7 @@ public static function getSupportedResources(): array
118118
119119 // Database
120120 Resource::TYPE_DATABASE ,
121+ Resource::TYPE_DOCUMENTSDB_DATABASE ,
121122 Resource::TYPE_TABLE ,
122123 Resource::TYPE_COLUMN ,
123124 Resource::TYPE_INDEX ,
@@ -282,18 +283,19 @@ public function importDatabaseResource(Resource $resource, bool $isLast): Resour
282283 {
283284 switch ($ resource ->getName ()) {
284285 case Resource::TYPE_DATABASE :
286+ case Resource::TYPE_DOCUMENTSDB_DATABASE :
285287 /** @var Database $resource */
286288 $ success = $ this ->createDatabase ($ resource );
287289 break ;
288290 case Resource::TYPE_TABLE :
289291 case Resource::TYPE_COLLECTION :
290292 /** @var Table $resource */
291- $ success = $ this ->createTable ($ resource );
293+ $ success = $ this ->createEntity ($ resource );
292294 break ;
293295 case Resource::TYPE_COLUMN :
294296 case Resource::TYPE_ATTRIBUTE :
295297 /** @var Column $resource */
296- $ success = $ this ->createColumn ($ resource );
298+ $ success = $ this ->createField ($ resource );
297299 break ;
298300 case Resource::TYPE_INDEX :
299301 /** @var Index $resource */
@@ -302,7 +304,7 @@ public function importDatabaseResource(Resource $resource, bool $isLast): Resour
302304 case Resource::TYPE_ROW :
303305 case Resource::TYPE_DOCUMENT :
304306 /** @var Row $resource */
305- $ success = $ this ->createRow ($ resource , $ isLast );
307+ $ success = $ this ->createRecord ($ resource , $ isLast );
306308 break ;
307309 default :
308310 $ success = false ;
@@ -377,7 +379,7 @@ protected function createDatabase(Database $resource): bool
377379 * @throws StructureException
378380 * @throws Exception
379381 */
380- protected function createTable (Table $ resource ): bool
382+ protected function createEntity (Table $ resource ): bool
381383 {
382384 if ($ resource ->getId () == 'unique() ' ) {
383385 $ resource ->setId (ID ::unique ());
@@ -439,7 +441,7 @@ protected function createTable(Table $resource): bool
439441 * @throws \Exception
440442 * @throws \Throwable
441443 */
442- protected function createColumn (Column $ resource ): bool
444+ protected function createField (Column $ resource ): bool
443445 {
444446 // Skip columns for documents DB (schemaless)
445447 if ($ resource ->getTable ()->getDatabase ()->getType () === 'documents ' ) {
@@ -922,7 +924,7 @@ protected function createIndex(Index $resource): bool
922924 * @throws StructureException
923925 * @throws Exception
924926 */
925- protected function createRow (Row $ resource , bool $ isLast ): bool
927+ protected function createRecord (Row $ resource , bool $ isLast ): bool
926928 {
927929 if ($ resource ->getId () == 'unique() ' ) {
928930 $ resource ->setId (ID ::unique ());
@@ -942,7 +944,7 @@ protected function createRow(Row $resource, bool $isLast): bool
942944 // Check if document has already been created
943945 $ exists = \array_key_exists (
944946 $ resource ->getId (),
945- $ this ->cache ->get (Resource:: TYPE_ROW )
947+ $ this ->cache ->get ($ resource -> getName () )
946948 );
947949
948950 if ($ exists ) {
@@ -972,32 +974,33 @@ protected function createRow(Row $resource, bool $isLast): bool
972974
973975 $ databaseInternalId = $ database ->getSequence ();
974976 $ tableInternalId = $ table ->getSequence ();
975-
977+ $ dbForDatabase = call_user_func ( $ this -> getDatabaseDB , $ database );
976978 /**
977979 * This is in case an attribute was deleted from Appwrite attributes collection but was not deleted from the table
978980 * When creating an archive we select * which will include orphan attribute from the schema
979981 */
980- foreach ($ this ->rowBuffer as $ row ) {
981- foreach ($ row as $ key => $ value ) {
982- if (\str_starts_with ($ key , '$ ' )) {
983- continue ;
984- }
985-
986- /** @var \Utopia\Database\Document $attribute */
987- $ found = false ;
988- foreach ($ table ->getAttribute ('attributes ' , []) as $ attribute ) {
989- if ($ attribute ->getAttribute ('key ' ) == $ key ) {
990- $ found = true ;
991- break ;
982+ if ($ dbForDatabase ->getAdapter ()->getSupportForAttributes ()){
983+ foreach ($ this ->rowBuffer as $ row ) {
984+ foreach ($ row as $ key => $ value ) {
985+ if (\str_starts_with ($ key , '$ ' )) {
986+ continue ;
987+ }
988+
989+ /** @var \Utopia\Database\Document $attribute */
990+ $ found = false ;
991+ foreach ($ table ->getAttribute ('attributes ' , []) as $ attribute ) {
992+ if ($ attribute ->getAttribute ('key ' ) == $ key ) {
993+ $ found = true ;
994+ break ;
995+ }
996+ }
997+
998+ if (! $ found ) {
999+ $ row ->removeAttribute ($ key );
9921000 }
993- }
994-
995- if (! $ found ) {
996- $ row ->removeAttribute ($ key );
9971001 }
9981002 }
9991003 }
1000- $ dbForDatabase = call_user_func ($ this ->getDatabaseDB , $ database );
10011004 $ dbForDatabase ->skipRelationshipsExistCheck (fn () => $ dbForDatabase ->createDocuments (
10021005 'database_ ' . $ databaseInternalId . '_collection_ ' . $ tableInternalId ,
10031006 $ this ->rowBuffer
0 commit comments