Skip to content

Conversation

@abnegate
Copy link
Member

@abnegate abnegate commented Dec 8, 2025

Summary by CodeRabbit

  • Chores

    • Removed support for legacy database flavors (DocumentsDB, VectorDB) and related resource types.
    • Removed many legacy attribute/column types from migration schemas.
    • Streamlined migration readers and CSV export to use a unified database flow.
  • Refactor

    • Simplified database connection handling across migration paths.
  • Bug Fixes

    • Adjusted cache key generation for certain table resources (affects cache indexing/lookups).

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR removes legacy database types and many database-related resource classes (attributes, collection, document, DocumentsDB, VectorDB), simplifies cache key generation by removing database type, and refactors source/destination readers and exporters to use a single concrete UtopiaDatabase instance. Constructors and numerous method signatures were changed (notably in Appwrite destination and Appwrite/Database readers), several public constants and resource groups in Transfer.php were removed, and CSV/source export flows were updated to use Database/Table/Row objects.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Areas requiring extra attention:

  • src/Migration/Destinations/Appwrite.php — constructor signature changes, replacement of callables with concrete UtopiaDatabase, many method renames and pervasive use of $this->database.
  • src/Migration/Sources/Appwrite.php — reader consolidation, removal of static factory helpers, and renaming of export methods (exportEntities → exportTables, exportFields → exportColumns, exportRecords → exportRows).
  • src/Migration/Sources/Appwrite/Reader/Database.php — constructor simplified, single-database access model, removal of getSupportForAttributes and logging.
  • src/Migration/Sources/Appwrite/Reader/API.php and Reader interface — removed getSupportForAttributes method; ensure callers are updated.
  • src/Migration/Sources/CSV.php — switching to Database/Table/Row objects and changes to CSV parsing (vector/object handling removed).
  • Massive deletions of attribute/column/resource classes (src/Migration/Resources/Database/**) — verify there are no remaining references or tests depending on removed classes (Attribute and its many subtypes, Collection, Document, DocumentsDB, VectorDB, ObjectType/Vector column classes).
  • src/Migration/Transfer.php — removal of several GROUP_* constants and resource group arrays; check for external usages.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Revert' is vague and does not clearly indicate what specific changes or features are being reverted in this changeset. Provide a more descriptive title that specifies what is being reverted, such as 'Revert: Remove support for DocumentsDB and VectorDB' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dc0108 and 7fcb7a1.

📒 Files selected for processing (2)
  • src/Migration/Sources/Appwrite.php (13 hunks)
  • src/Migration/Sources/Appwrite/Reader/Database.php (5 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/Migration/Sources/Appwrite/Reader/Database.php (1)

5-5: Remove unused import Utopia\Console.

The Console class is imported but never used in this file. This is causing the pipeline lint failure.

-use Utopia\Console;
src/Migration/Sources/Appwrite.php (1)

1234-1234: Fix undefined variable $entityName.

The variable $entityName is never defined in exportRows(), causing a PHP error. This was flagged by the PHPStan pipeline failure.

This appears to be leftover from the entity-to-table terminology refactoring. Consider removing this debug log line or fixing the variable reference.

-$this->logDebugTrackedProject("exportRecords completed | Entity: {$entityName}");
+$this->logDebugTrackedProject("exportRows completed");
🧹 Nitpick comments (2)
src/Migration/Destinations/Appwrite.php (2)

799-802: Remove unused variable $columnSize.

The $columnSize variable is assigned but never used. This was flagged by static analysis.

 $columnStatus = $oldColumns[$columnIndex]['status'];
 $columnType = $oldColumns[$columnIndex]['type'];
-$columnSize = $oldColumns[$columnIndex]['size'];
 $columnArray = $oldColumns[$columnIndex]['array'] ?? false;

969-988: Remove unused $value variable in foreach loop.

The $value variable is never used in the loop body; only $key is needed. This was flagged by static analysis.

 foreach ($this->rowBuffer as $row) {
-    foreach ($row as $key => $value) {
+    foreach ($row as $key => $_) {
         if (\str_starts_with($key, '$')) {
             continue;
         }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 409983b and 2dc0108.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (33)
  • src/Migration/Cache.php (0 hunks)
  • src/Migration/Destinations/Appwrite.php (34 hunks)
  • src/Migration/Resource.php (0 hunks)
  • src/Migration/Resources/Database/Attribute.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Boolean.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/DateTime.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Decimal.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Email.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Enum.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/IP.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Integer.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Line.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/ObjectType.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Point.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Polygon.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Relationship.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Text.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/URL.php (0 hunks)
  • src/Migration/Resources/Database/Attribute/Vector.php (0 hunks)
  • src/Migration/Resources/Database/Collection.php (0 hunks)
  • src/Migration/Resources/Database/Column.php (0 hunks)
  • src/Migration/Resources/Database/Columns/ObjectType.php (0 hunks)
  • src/Migration/Resources/Database/Columns/Vector.php (0 hunks)
  • src/Migration/Resources/Database/Database.php (0 hunks)
  • src/Migration/Resources/Database/Document.php (0 hunks)
  • src/Migration/Resources/Database/DocumentsDB.php (0 hunks)
  • src/Migration/Resources/Database/VectorDB.php (0 hunks)
  • src/Migration/Sources/Appwrite.php (14 hunks)
  • src/Migration/Sources/Appwrite/Reader.php (0 hunks)
  • src/Migration/Sources/Appwrite/Reader/API.php (0 hunks)
  • src/Migration/Sources/Appwrite/Reader/Database.php (5 hunks)
  • src/Migration/Sources/CSV.php (7 hunks)
  • src/Migration/Transfer.php (1 hunks)
💤 Files with no reviewable changes (28)
  • src/Migration/Resources/Database/Collection.php
  • src/Migration/Sources/Appwrite/Reader/API.php
  • src/Migration/Resources/Database/Attribute/Decimal.php
  • src/Migration/Resources/Database/Column.php
  • src/Migration/Resources/Database/DocumentsDB.php
  • src/Migration/Resources/Database/Columns/ObjectType.php
  • src/Migration/Resources/Database/Attribute/Line.php
  • src/Migration/Resources/Database/Attribute/URL.php
  • src/Migration/Resources/Database/Attribute/IP.php
  • src/Migration/Cache.php
  • src/Migration/Resources/Database/Columns/Vector.php
  • src/Migration/Resources/Database/Document.php
  • src/Migration/Sources/Appwrite/Reader.php
  • src/Migration/Resources/Database/VectorDB.php
  • src/Migration/Resources/Database/Attribute/Enum.php
  • src/Migration/Resources/Database/Attribute/Point.php
  • src/Migration/Resources/Database/Attribute/ObjectType.php
  • src/Migration/Resources/Database/Attribute/DateTime.php
  • src/Migration/Resources/Database/Attribute/Email.php
  • src/Migration/Resources/Database/Attribute/Vector.php
  • src/Migration/Resources/Database/Database.php
  • src/Migration/Resources/Database/Attribute/Integer.php
  • src/Migration/Resources/Database/Attribute/Boolean.php
  • src/Migration/Resource.php
  • src/Migration/Resources/Database/Attribute/Relationship.php
  • src/Migration/Resources/Database/Attribute/Polygon.php
  • src/Migration/Resources/Database/Attribute/Text.php
  • src/Migration/Resources/Database/Attribute.php
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: ItzNotABug
Repo: utopia-php/migration PR: 80
File: src/Migration/Sources/Supabase.php:300-308
Timestamp: 2025-06-28T09:47:58.757Z
Learning: In the utopia-php/migration codebase, during the terminology swap from Collection/Attribute/Document to Table/Column/Row, the user ItzNotABug prefers to keep the existing query logic unchanged even if it becomes semantically incorrect with the new naming. The focus is purely on resource type renaming, not on fixing logical issues that become apparent after the terminology change.
Learnt from: ItzNotABug
Repo: utopia-php/migration PR: 80
File: src/Migration/Sources/Appwrite.php:843-851
Timestamp: 2025-06-28T09:47:08.333Z
Learning: In the utopia-php/migration codebase, during the terminology swap from Collection/Attribute/Document to Table/Column/Row, the class constructors and method parameters use the new terminology (like "relatedTable"), but the underlying data structures and API responses still use the legacy keys (like "relatedCollection"). This is an intentional design pattern to allow gradual migration while maintaining compatibility with existing data sources.
Learnt from: ItzNotABug
Repo: utopia-php/migration PR: 80
File: src/Migration/Sources/Appwrite/Reader/API.php:8-8
Timestamp: 2025-06-28T09:47:11.436Z
Learning: In the Appwrite migration codebase, commented-out Tables service references (import statements and constructor parameters) are intentionally kept for future implementation when the Tables service becomes available in the Appwrite SDK, rather than being dead code that should be removed.
📚 Learning: 2025-06-28T09:47:08.333Z
Learnt from: ItzNotABug
Repo: utopia-php/migration PR: 80
File: src/Migration/Sources/Appwrite.php:843-851
Timestamp: 2025-06-28T09:47:08.333Z
Learning: In the utopia-php/migration codebase, during the terminology swap from Collection/Attribute/Document to Table/Column/Row, the class constructors and method parameters use the new terminology (like "relatedTable"), but the underlying data structures and API responses still use the legacy keys (like "relatedCollection"). This is an intentional design pattern to allow gradual migration while maintaining compatibility with existing data sources.

Applied to files:

  • src/Migration/Destinations/Appwrite.php
  • src/Migration/Sources/CSV.php
  • src/Migration/Sources/Appwrite/Reader/Database.php
  • src/Migration/Transfer.php
  • src/Migration/Sources/Appwrite.php
📚 Learning: 2025-06-28T09:47:58.757Z
Learnt from: ItzNotABug
Repo: utopia-php/migration PR: 80
File: src/Migration/Sources/Supabase.php:300-308
Timestamp: 2025-06-28T09:47:58.757Z
Learning: In the utopia-php/migration codebase, during the terminology swap from Collection/Attribute/Document to Table/Column/Row, the user ItzNotABug prefers to keep the existing query logic unchanged even if it becomes semantically incorrect with the new naming. The focus is purely on resource type renaming, not on fixing logical issues that become apparent after the terminology change.

Applied to files:

  • src/Migration/Destinations/Appwrite.php
  • src/Migration/Sources/CSV.php
  • src/Migration/Sources/Appwrite/Reader/Database.php
  • src/Migration/Transfer.php
  • src/Migration/Sources/Appwrite.php
📚 Learning: 2025-06-28T09:47:11.436Z
Learnt from: ItzNotABug
Repo: utopia-php/migration PR: 80
File: src/Migration/Sources/Appwrite/Reader/API.php:8-8
Timestamp: 2025-06-28T09:47:11.436Z
Learning: In the Appwrite migration codebase, commented-out Tables service references (import statements and constructor parameters) are intentionally kept for future implementation when the Tables service becomes available in the Appwrite SDK, rather than being dead code that should be removed.

Applied to files:

  • src/Migration/Destinations/Appwrite.php
  • src/Migration/Sources/Appwrite.php
📚 Learning: 2025-11-20T13:07:39.293Z
Learnt from: ArnabChatterjee20k
Repo: utopia-php/migration PR: 114
File: src/Migration/Resources/Database/Attribute/Decimal.php:10-38
Timestamp: 2025-11-20T13:07:39.293Z
Learning: In the utopia-php/migration codebase, the user ArnabChatterjee20k maintains consistency between parallel implementations: Attribute classes (e.g., Attribute/Decimal.php) mirror their corresponding Column classes (e.g., Columns/Decimal.php) in constructor defaults and behavior, even when design decisions might be questioned.

Applied to files:

  • src/Migration/Destinations/Appwrite.php
  • src/Migration/Sources/CSV.php
  • src/Migration/Sources/Appwrite/Reader/Database.php
  • src/Migration/Sources/Appwrite.php
📚 Learning: 2025-07-30T12:06:02.331Z
Learnt from: abnegate
Repo: utopia-php/migration PR: 0
File: :0-0
Timestamp: 2025-07-30T12:06:02.331Z
Learning: In the utopia-php/migration codebase, the Utopia Database package does not have a Memory adapter. When testing classes that require a Database instance (like CSV), use PHPUnit's createMock() method to create proper mocks instead of trying to instantiate real database adapters.

Applied to files:

  • src/Migration/Destinations/Appwrite.php
  • src/Migration/Sources/CSV.php
  • src/Migration/Sources/Appwrite/Reader/Database.php
  • src/Migration/Sources/Appwrite.php
📚 Learning: 2025-06-28T09:45:57.650Z
Learnt from: ItzNotABug
Repo: utopia-php/migration PR: 80
File: src/Migration/Resources/Database/Columns/Relationship.php:86-89
Timestamp: 2025-06-28T09:45:57.650Z
Learning: In the utopia-php/migration codebase Relationship column class, the `getRelatedTable()` method intentionally returns `$this->options['relatedCollection']` (not `relatedTable`) because the underlying API still uses "collection" terminology, even though the internal codebase has been refactored to use "table" terminology.

Applied to files:

  • src/Migration/Destinations/Appwrite.php
📚 Learning: 2025-06-28T09:45:36.026Z
Learnt from: ItzNotABug
Repo: utopia-php/migration PR: 80
File: src/Migration/Resources/Database/Row.php:60-60
Timestamp: 2025-06-28T09:45:36.026Z
Learning: In the utopia-php/migration codebase, the `fromArray` method is not used on Row objects, so mismatches between `jsonSerialize()` output keys and `fromArray()` input expectations for Row class are not problematic.

Applied to files:

  • src/Migration/Sources/CSV.php
  • src/Migration/Sources/Appwrite/Reader/Database.php
📚 Learning: 2025-07-02T06:24:50.844Z
Learnt from: ItzNotABug
Repo: utopia-php/migration PR: 81
File: src/Migration/Sources/CSV.php:215-233
Timestamp: 2025-07-02T06:24:50.844Z
Learning: In the utopia-php/migration codebase, invalid numeric values (like null) in parsed data are acceptable because the underlying database structure validator will catch and handle these validation errors, so explicit filtering during parsing is not required.

Applied to files:

  • src/Migration/Sources/CSV.php
  • src/Migration/Sources/Appwrite/Reader/Database.php
  • src/Migration/Sources/Appwrite.php
📚 Learning: 2025-11-20T13:12:43.482Z
Learnt from: ArnabChatterjee20k
Repo: utopia-php/migration PR: 114
File: src/Migration/Resources/Database/Collection.php:14-37
Timestamp: 2025-11-20T13:12:43.482Z
Learning: In the utopia-php/migration codebase, when Collection::fromArray is called, the input array is guaranteed to contain both the 'database' key and the nested 'type' key ($array['database']['type']), so defensive guards for these keys are not necessary.

Applied to files:

  • src/Migration/Sources/CSV.php
  • src/Migration/Sources/Appwrite/Reader/Database.php
  • src/Migration/Sources/Appwrite.php
🧬 Code graph analysis (4)
src/Migration/Destinations/Appwrite.php (9)
src/Migration/Sources/Appwrite.php (1)
  • getName (113-116)
src/Migration/Resources/Database/Database.php (3)
  • getType (91-94)
  • getName (71-74)
  • getGroup (76-79)
src/Migration/Resources/Database/Column.php (5)
  • Column (8-155)
  • getType (85-85)
  • getName (80-83)
  • getGroup (87-90)
  • getTable (97-100)
src/Migration/Resources/Database/Index.php (4)
  • getType (129-132)
  • getName (109-112)
  • getGroup (114-117)
  • getTable (124-127)
src/Migration/Resources/Auth/User.php (2)
  • getName (83-86)
  • getGroup (153-156)
src/Migration/Exception.php (1)
  • Exception (5-65)
src/Migration/Resource.php (5)
  • Resource (5-236)
  • getSequence (151-154)
  • getId (127-130)
  • getName (108-108)
  • getGroup (110-110)
src/Migration/Resources/Database/Table.php (4)
  • Table (8-110)
  • getName (81-84)
  • getGroup (86-89)
  • getDatabase (91-94)
bin/MigrationCLI.php (1)
  • getDatabase (265-399)
src/Migration/Sources/Appwrite/Reader/Database.php (2)
src/Migration/Sources/Appwrite/Reader/API.php (3)
  • report (28-118)
  • listDatabases (123-126)
  • listTables (131-138)
src/Migration/Resource.php (3)
  • Resource (5-236)
  • isSupported (112-125)
  • getId (127-130)
src/Migration/Transfer.php (1)
src/Migration/Exception.php (1)
  • Exception (5-65)
src/Migration/Sources/Appwrite.php (1)
src/Migration/Sources/Appwrite/Reader/Database.php (11)
  • queryLimit (413-416)
  • queryEqual (371-374)
  • queryCursorAfter (382-411)
  • listDatabases (113-116)
  • Database (23-428)
  • listTables (118-157)
  • listColumns (159-219)
  • listIndexes (221-266)
  • querySelect (361-364)
  • listRows (268-316)
  • getRow (318-355)
🪛 GitHub Actions: CodeQL
src/Migration/Sources/Appwrite.php

[error] 1234-1234: PHPStan: Undefined variable: $entityName.

🪛 GitHub Actions: Linter
src/Migration/Sources/Appwrite/Reader/Database.php

[error] 1-1: Pint lint failed. Command './vendor/bin/pint --test' returned exit code 1 due to PSR-12: no_unused_imports.

🪛 PHPMD (2.15.0)
src/Migration/Destinations/Appwrite.php

801-801: Avoid unused local variables such as '$columnSize'. (undefined)

(UnusedLocalVariable)


970-970: Avoid unused local variables such as '$value'. (undefined)

(UnusedLocalVariable)

🔇 Additional comments (10)
src/Migration/Sources/Appwrite/Reader/Database.php (1)

25-27: LGTM!

The simplified constructor accepting a single UtopiaDatabase instance is cleaner and aligns with the database-centric refactoring approach.

src/Migration/Sources/CSV.php (3)

43-53: LGTM!

Constructor simplification and direct DatabaseReader instantiation align well with the database-centric refactoring.


134-136: LGTM!

Creating lightweight Database and Table objects with just the required IDs is appropriate for the CSV import context where full metadata isn't needed.


314-319: LGTM!

Row creation using the new Row resource class is cleaner than the previous approach.

src/Migration/Transfer.php (2)

37-43: LGTM!

The consolidated GROUP_DATABASES_RESOURCES constant properly reflects the simplified database resource model.


62-66: Good backward compatibility consideration.

Keeping legacy types (TYPE_DOCUMENT, TYPE_ATTRIBUTE, TYPE_COLLECTION) in ALL_PUBLIC_RESOURCES maintains backward compatibility for existing migrations.

src/Migration/Destinations/Appwrite.php (2)

72-77: LGTM!

The constructor now properly accepts a concrete UtopiaDatabase instance, simplifying dependency management and aligning with the database-centric architecture.


426-443: LGTM!

The column type mapping comprehensively covers all supported types with proper mapping to UtopiaDatabase constants.

src/Migration/Sources/Appwrite.php (2)

98-110: LGTM!

The switch-based initialization properly guards against missing database for SOURCE_DATABASE and provides clear error messaging.


1146-1165: LGTM!

The many-to-many relationship handling properly filters for parent-side relationship columns before processing.

@abnegate abnegate merged commit f7b4823 into main Dec 8, 2025
3 of 4 checks passed
@abnegate abnegate deleted the revert-feat-documents-db branch December 8, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants