@@ -332,7 +332,7 @@ protected function createDatabase(Database $resource): bool
332332 'originalId ' => empty ($ resource ->getOriginalId ()) ? null : $ resource ->getOriginalId (),
333333 ]));
334334
335- $ resource ->setInternalId ($ database ->getInternalId ());
335+ $ resource ->setSequence ($ database ->getSequence ());
336336
337337 $ attributes = \array_map (
338338 fn ($ attr ) => new UtopiaDocument ($ attr ),
@@ -344,7 +344,7 @@ protected function createDatabase(Database $resource): bool
344344 );
345345
346346 $ this ->database ->createCollection (
347- 'database_ ' . $ database ->getInternalId (),
347+ 'database_ ' . $ database ->getSequence (),
348348 $ attributes ,
349349 $ indexes
350350 );
@@ -389,9 +389,9 @@ protected function createCollection(Collection $resource): bool
389389 );
390390 }
391391
392- $ collection = $ this ->database ->createDocument ('database_ ' . $ database ->getInternalId (), new UtopiaDocument ([
392+ $ collection = $ this ->database ->createDocument ('database_ ' . $ database ->getSequence (), new UtopiaDocument ([
393393 '$id ' => $ resource ->getId (),
394- 'databaseInternalId ' => $ database ->getInternalId (),
394+ 'databaseInternalId ' => $ database ->getSequence (),
395395 'databaseId ' => $ resource ->getDatabase ()->getId (),
396396 '$permissions ' => Permission::aggregate ($ resource ->getPermissions ()),
397397 'documentSecurity ' => $ resource ->getDocumentSecurity (),
@@ -402,10 +402,10 @@ protected function createCollection(Collection $resource): bool
402402 '$updatedAt ' => $ resource ->getUpdatedAt (),
403403 ]));
404404
405- $ resource ->setInternalId ($ collection ->getInternalId ());
405+ $ resource ->setSequence ($ collection ->getSequence ());
406406
407407 $ this ->database ->createCollection (
408- 'database_ ' . $ database ->getInternalId () . '_collection_ ' . $ resource ->getInternalId (),
408+ 'database_ ' . $ database ->getSequence () . '_collection_ ' . $ resource ->getSequence (),
409409 permissions: $ resource ->getPermissions (),
410410 documentSecurity: $ resource ->getDocumentSecurity ()
411411 );
@@ -449,7 +449,7 @@ protected function createAttribute(Attribute $resource): bool
449449 }
450450
451451 $ collection = $ this ->database ->getDocument (
452- 'database_ ' . $ database ->getInternalId (),
452+ 'database_ ' . $ database ->getSequence (),
453453 $ resource ->getCollection ()->getId (),
454454 );
455455
@@ -491,7 +491,7 @@ protected function createAttribute(Attribute $resource): bool
491491 if ($ type === UtopiaDatabase::VAR_RELATIONSHIP ) {
492492 $ resource ->getOptions ()['side ' ] = UtopiaDatabase::RELATION_SIDE_PARENT ;
493493 $ relatedCollection = $ this ->database ->getDocument (
494- 'database_ ' . $ database ->getInternalId (),
494+ 'database_ ' . $ database ->getSequence (),
495495 $ resource ->getOptions ()['relatedCollection ' ]
496496 );
497497 if ($ relatedCollection ->isEmpty ()) {
@@ -506,11 +506,11 @@ protected function createAttribute(Attribute $resource): bool
506506
507507 try {
508508 $ attribute = new UtopiaDocument ([
509- '$id ' => ID ::custom ($ database ->getInternalId () . '_ ' . $ collection ->getInternalId () . '_ ' . $ resource ->getKey ()),
509+ '$id ' => ID ::custom ($ database ->getSequence () . '_ ' . $ collection ->getSequence () . '_ ' . $ resource ->getKey ()),
510510 'key ' => $ resource ->getKey (),
511- 'databaseInternalId ' => $ database ->getInternalId (),
511+ 'databaseInternalId ' => $ database ->getSequence (),
512512 'databaseId ' => $ database ->getId (),
513- 'collectionInternalId ' => $ collection ->getInternalId (),
513+ 'collectionInternalId ' => $ collection ->getSequence (),
514514 'collectionId ' => $ collection ->getId (),
515515 'type ' => $ type ,
516516 'status ' => 'available ' ,
@@ -545,13 +545,13 @@ protected function createAttribute(Attribute $resource): bool
545545 message: 'Attribute limit exceeded ' ,
546546 );
547547 } catch (\Throwable $ e ) {
548- $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getInternalId (), $ collection ->getId ());
549- $ this ->database ->purgeCachedCollection ('database_ ' . $ database ->getInternalId () . '_collection_ ' . $ collection ->getInternalId ());
548+ $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getSequence (), $ collection ->getId ());
549+ $ this ->database ->purgeCachedCollection ('database_ ' . $ database ->getSequence () . '_collection_ ' . $ collection ->getSequence ());
550550 throw $ e ;
551551 }
552552
553- $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getInternalId (), $ collection ->getId ());
554- $ this ->database ->purgeCachedCollection ('database_ ' . $ database ->getInternalId () . '_collection_ ' . $ collection ->getInternalId ());
553+ $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getSequence (), $ collection ->getId ());
554+ $ this ->database ->purgeCachedCollection ('database_ ' . $ database ->getSequence () . '_collection_ ' . $ collection ->getSequence ());
555555 $ options = $ resource ->getOptions ();
556556
557557 $ twoWayKey = null ;
@@ -564,11 +564,11 @@ protected function createAttribute(Attribute $resource): bool
564564
565565 try {
566566 $ twoWayAttribute = new UtopiaDocument ([
567- '$id ' => ID ::custom ($ database ->getInternalId () . '_ ' . $ relatedCollection ->getInternalId () . '_ ' . $ twoWayKey ),
567+ '$id ' => ID ::custom ($ database ->getSequence () . '_ ' . $ relatedCollection ->getSequence () . '_ ' . $ twoWayKey ),
568568 'key ' => $ twoWayKey ,
569- 'databaseInternalId ' => $ database ->getInternalId (),
569+ 'databaseInternalId ' => $ database ->getSequence (),
570570 'databaseId ' => $ database ->getId (),
571- 'collectionInternalId ' => $ relatedCollection ->getInternalId (),
571+ 'collectionInternalId ' => $ relatedCollection ->getSequence (),
572572 'collectionId ' => $ relatedCollection ->getId (),
573573 'type ' => $ type ,
574574 'status ' => 'available ' ,
@@ -605,8 +605,8 @@ protected function createAttribute(Attribute $resource): bool
605605 message: 'Attribute limit exceeded ' ,
606606 );
607607 } catch (\Throwable $ e ) {
608- $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getInternalId (), $ relatedCollection ->getId ());
609- $ this ->database ->purgeCachedCollection ('database_ ' . $ database ->getInternalId () . '_collection_ ' . $ relatedCollection ->getInternalId ());
608+ $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getSequence (), $ relatedCollection ->getId ());
609+ $ this ->database ->purgeCachedCollection ('database_ ' . $ database ->getSequence () . '_collection_ ' . $ relatedCollection ->getSequence ());
610610 throw $ e ;
611611 }
612612 }
@@ -615,8 +615,8 @@ protected function createAttribute(Attribute $resource): bool
615615 switch ($ type ) {
616616 case UtopiaDatabase::VAR_RELATIONSHIP :
617617 if (!$ this ->database ->createRelationship (
618- collection: 'database_ ' . $ database ->getInternalId () . '_collection_ ' . $ collection ->getInternalId (),
619- relatedCollection: 'database_ ' . $ database ->getInternalId () . '_collection_ ' . $ relatedCollection ->getInternalId (),
618+ collection: 'database_ ' . $ database ->getSequence () . '_collection_ ' . $ collection ->getSequence (),
619+ relatedCollection: 'database_ ' . $ database ->getSequence () . '_collection_ ' . $ relatedCollection ->getSequence (),
620620 type: $ options ['relationType ' ],
621621 twoWay: $ options ['twoWay ' ],
622622 id: $ resource ->getKey (),
@@ -633,7 +633,7 @@ protected function createAttribute(Attribute $resource): bool
633633 break ;
634634 default :
635635 if (!$ this ->database ->createAttribute (
636- 'database_ ' . $ database ->getInternalId () . '_collection_ ' . $ collection ->getInternalId (),
636+ 'database_ ' . $ database ->getSequence () . '_collection_ ' . $ collection ->getSequence (),
637637 $ resource ->getKey (),
638638 $ type ,
639639 $ resource ->getSize (),
@@ -664,11 +664,11 @@ protected function createAttribute(Attribute $resource): bool
664664 }
665665
666666 if ($ type === UtopiaDatabase::VAR_RELATIONSHIP && $ options ['twoWay ' ]) {
667- $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getInternalId (), $ relatedCollection ->getId ());
667+ $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getSequence (), $ relatedCollection ->getId ());
668668 }
669669
670- $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getInternalId (), $ collection ->getId ());
671- $ this ->database ->purgeCachedCollection ('database_ ' . $ database ->getInternalId () . '_collection_ ' . $ collection ->getInternalId ());
670+ $ this ->database ->purgeCachedDocument ('database_ ' . $ database ->getSequence (), $ collection ->getId ());
671+ $ this ->database ->purgeCachedCollection ('database_ ' . $ database ->getSequence () . '_collection_ ' . $ collection ->getSequence ());
672672
673673 return true ;
674674 }
@@ -693,7 +693,7 @@ protected function createIndex(Index $resource): bool
693693 }
694694
695695 $ collection = $ this ->database ->getDocument (
696- 'database_ ' . $ database ->getInternalId (),
696+ 'database_ ' . $ database ->getSequence (),
697697 $ resource ->getCollection ()->getId (),
698698 );
699699 if ($ collection ->isEmpty ()) {
@@ -706,8 +706,8 @@ protected function createIndex(Index $resource): bool
706706 }
707707
708708 $ count = $ this ->database ->count ('indexes ' , [
709- Query::equal ('collectionInternalId ' , [$ collection ->getInternalId ()]),
710- Query::equal ('databaseInternalId ' , [$ database ->getInternalId ()])
709+ Query::equal ('collectionInternalId ' , [$ collection ->getSequence ()]),
710+ Query::equal ('databaseInternalId ' , [$ database ->getSequence ()])
711711 ], $ this ->database ->getLimitForIndexes ());
712712
713713 if ($ count >= $ this ->database ->getLimitForIndexes ()) {
@@ -810,12 +810,12 @@ protected function createIndex(Index $resource): bool
810810 }
811811
812812 $ index = new UtopiaDocument ([
813- '$id ' => ID ::custom ($ database ->getInternalId () . '_ ' . $ collection ->getInternalId () . '_ ' . $ resource ->getKey ()),
813+ '$id ' => ID ::custom ($ database ->getSequence () . '_ ' . $ collection ->getSequence () . '_ ' . $ resource ->getKey ()),
814814 'key ' => $ resource ->getKey (),
815815 'status ' => 'available ' , // processing, available, failed, deleting, stuck
816- 'databaseInternalId ' => $ database ->getInternalId (),
816+ 'databaseInternalId ' => $ database ->getSequence (),
817817 'databaseId ' => $ database ->getId (),
818- 'collectionInternalId ' => $ collection ->getInternalId (),
818+ 'collectionInternalId ' => $ collection ->getSequence (),
819819 'collectionId ' => $ collection ->getId (),
820820 'type ' => $ resource ->getType (),
821821 'attributes ' => $ resource ->getAttributes (),
@@ -844,7 +844,7 @@ protected function createIndex(Index $resource): bool
844844
845845 try {
846846 $ result = $ this ->database ->createIndex (
847- 'database_ ' . $ database ->getInternalId () . '_collection_ ' . $ collection ->getInternalId (),
847+ 'database_ ' . $ database ->getSequence () . '_collection_ ' . $ collection ->getSequence (),
848848 $ resource ->getKey (),
849849 $ resource ->getType (),
850850 $ resource ->getAttributes (),
@@ -872,7 +872,7 @@ protected function createIndex(Index $resource): bool
872872 }
873873
874874 $ this ->database ->purgeCachedDocument (
875- 'database_ ' . $ database ->getInternalId (),
875+ 'database_ ' . $ database ->getSequence (),
876876 $ collection ->getId ()
877877 );
878878
@@ -928,12 +928,12 @@ protected function createDocument(Document $resource, bool $isLast): bool
928928 $ resource ->getCollection ()->getDatabase ()->getId (),
929929 );
930930 $ collection = $ this ->database ->getDocument (
931- 'database_ ' . $ database ->getInternalId (),
931+ 'database_ ' . $ database ->getSequence (),
932932 $ resource ->getCollection ()->getId (),
933933 );
934934
935- $ databaseInternalId = $ database ->getInternalId ();
936- $ collectionInternalId = $ collection ->getInternalId ();
935+ $ databaseInternalId = $ database ->getSequence ();
936+ $ collectionInternalId = $ collection ->getSequence ();
937937
938938 /**
939939 * This is in case an attribute was deleted from Appwrite attributes collection but was not deleted from the table
0 commit comments