From 01c8dab34d5b1d441e632164bac0d4c73a0d59db Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 30 Jul 2025 16:46:14 +1200 Subject: [PATCH 1/6] Fix CSV success test --- .../Services/Migrations/MigrationsBase.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 6bc1f2d427..fd05019b80 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -903,7 +903,7 @@ trait MigrationsBase */ public function testCreateCsvMigration(): array { - // make a database + // Make a database $response = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -1112,7 +1112,7 @@ trait MigrationsBase ); }, 60000, 500); - // all data exists, pass/ + // all data exists, pass. $migration = $this->performCsvMigration( [ 'endpoint' => 'http://localhost/v1', @@ -1122,11 +1122,22 @@ trait MigrationsBase ] ); - $this->assertEmpty($migration['body']['statusCounters']); - $this->assertEquals('CSV', $migration['body']['source']); - $this->assertEquals('pending', $migration['body']['status']); - $this->assertEquals('Appwrite', $migration['body']['destination']); - $this->assertContains(Resource::TYPE_DOCUMENT, $migration['body']['resources']); + $this->assertEventually(function () use ($migration, $databaseId, $collectionId) { + $migrationId = $migration['body']['$id']; + $migration = $this->client->call(Client::METHOD_GET, '/migrations/'.$migrationId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $migration['headers']['status-code']); + $this->assertEquals('finished', $migration['body']['stage']); + $this->assertEquals('completed', $migration['body']['status']); + $this->assertEquals('CSV', $migration['body']['source']); + $this->assertEquals('Appwrite', $migration['body']['destination']); + $this->assertContains(Resource::TYPE_DOCUMENT, $migration['body']['resources']); + $this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']); + $this->assertEquals(100, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']); + }, 60_000, 500); return [ 'databaseId' => $databaseId, From 5b12a6c8b1dc0e994f21a64ab9dfdb4612037dbd Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 30 Jul 2025 16:50:09 +1200 Subject: [PATCH 2/6] Add internal attributes CSV test --- composer.json | 2 +- composer.lock | 27 ++++++++++------ .../Services/Migrations/MigrationsBase.php | 31 ++++++++++++++++++- tests/resources/csv/documents-internals.csv | 26 ++++++++++++++++ 4 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 tests/resources/csv/documents-internals.csv diff --git a/composer.json b/composer.json index 31a31af9f2..f9e22b5557 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "utopia-php/locale": "0.4.*", "utopia-php/logger": "0.6.*", "utopia-php/messaging": "0.18.*", - "utopia-php/migration": "0.11.*", + "utopia-php/migration": "dev-feat-csv-allow-internals as 0.11.2", "utopia-php/orchestration": "0.9.*", "utopia-php/platform": "0.7.*", "utopia-php/pools": "0.8.*", diff --git a/composer.lock b/composer.lock index 5cd409fac6..83ebd15beb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "edbe5912c45e1f467f398541a75a77de", + "content-hash": "2a397a40480933a873d9d8bdca81c78d", "packages": [ { "name": "adhocore/jwt", @@ -3993,16 +3993,16 @@ }, { "name": "utopia-php/migration", - "version": "0.11.2", + "version": "dev-feat-csv-allow-internals", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "00f2b8e9927883f611e4e1ff179fa79e6bb2a12a" + "reference": "b4a33e84feec22f44e0181d32a7af10a199a82bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/00f2b8e9927883f611e4e1ff179fa79e6bb2a12a", - "reference": "00f2b8e9927883f611e4e1ff179fa79e6bb2a12a", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/b4a33e84feec22f44e0181d32a7af10a199a82bf", + "reference": "b4a33e84feec22f44e0181d32a7af10a199a82bf", "shasum": "" }, "require": { @@ -4043,9 +4043,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.11.2" + "source": "https://github.com/utopia-php/migration/tree/feat-csv-allow-internals" }, - "time": "2025-07-29T04:27:20+00:00" + "time": "2025-07-30T04:29:20+00:00" }, { "name": "utopia-php/orchestration", @@ -8237,9 +8237,18 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/migration", + "version": "dev-feat-csv-allow-internals", + "alias": "0.11.2", + "alias_normalized": "0.11.2.0" + } + ], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "utopia-php/migration": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index fd05019b80..124f7d1a37 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -992,6 +992,7 @@ trait MigrationsBase 'missing-row' => $bucketOneId, 'missing-column' => $bucketOneId, 'irrelevant-column' => $bucketOneId, + 'documents-internals' => $bucketOneId, ]; $fileIds = []; @@ -1000,7 +1001,8 @@ trait MigrationsBase $csvFileName = match ($label) { 'missing-row', 'missing-column', - 'irrelevant-column' => "{$label}.csv", + 'irrelevant-column', + 'documents-internals' => "{$label}.csv", default => 'documents.csv', }; @@ -1139,6 +1141,33 @@ trait MigrationsBase $this->assertEquals(100, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']); }, 60_000, 500); + // all data exists and includes internals, pass. + $migration = $this->performCsvMigration( + [ + 'endpoint' => 'http://localhost/v1', + 'fileId' => $fileIds['documents-internals'], + 'bucketId' => $bucketIds['documents-internals'], + 'resourceId' => $databaseId . ':' . $collectionId, + ] + ); + + $this->assertEventually(function () use ($migration, $databaseId, $collectionId) { + $migrationId = $migration['body']['$id']; + $migration = $this->client->call(Client::METHOD_GET, '/migrations/'.$migrationId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $migration['headers']['status-code']); + $this->assertEquals('finished', $migration['body']['stage']); + $this->assertEquals('completed', $migration['body']['status']); + $this->assertEquals('CSV', $migration['body']['source']); + $this->assertEquals('Appwrite', $migration['body']['destination']); + $this->assertContains(Resource::TYPE_DOCUMENT, $migration['body']['resources']); + $this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']); + $this->assertEquals(25, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']); + }, 60_000, 500); + return [ 'databaseId' => $databaseId, 'collectionId' => $collectionId, diff --git a/tests/resources/csv/documents-internals.csv b/tests/resources/csv/documents-internals.csv new file mode 100644 index 0000000000..c72df314b7 --- /dev/null +++ b/tests/resources/csv/documents-internals.csv @@ -0,0 +1,26 @@ +$id,$createdAt,$updatedAt,name,age +z1y2x3w4v5u6t7s8,2022-10-23T10:33:01+00:00,2023-03-15T12:00:41+00:00,Diamond Mendez,56 +r9q0p1o2n3m4l5k6,2021-08-11T21:05:13+00:00,2024-01-02T08:45:22+00:00,Michael Huff,20 +j7i8h9g0f1e2d3c4,2020-05-29T14:22:56+00:00,2022-11-30T18:19:33+00:00,Alyssa Rodriguez,37 +b5a6z7y8x9w0v1u2,2023-01-18T03:44:09+00:00,2023-09-07T23:50:17+00:00,Barbara Smith,26 +t3s4r5q6p7o8n9m0,2020-11-02T09:12:45+00:00,2021-07-21T15:30:55+00:00,Evelyn Edwards,54 +l1k2j3i4h5g6f7e8,2022-03-19T19:55:27+00:00,2024-05-14T06:28:11+00:00,Tina Richardson,41 +d9c0b1a2z3y4x5w6,2021-04-07T01:18:34+00:00,2023-06-25T11:47:04+00:00,Joel Hernandez,49 +v7u8t9s0r1q2p3o4,2023-08-22T16:40:18+00:00,2024-02-19T04:09:58+00:00,Zachary Cooper,59 +n5m6l7k8j9i0h1g2,2020-02-12T07:59:01+00:00,2022-09-08T13:21:49+00:00,Brittany Spears,20 +f3e4d5c6b7a8z9y0,2021-12-05T22:33:12+00:00,2023-11-11T02:55:37+00:00,Holly White,47 +x1w2v3u4t5s6r7q8,2022-07-14T05:01:50+00:00,2024-04-01T20:10:26+00:00,Kimberly Barnes,27 +p9o0n1m2l3k4j5i6,2020-09-28T11:27:36+00:00,2021-10-17T09:38:08+00:00,Stephen Miller,53 +h7g8f9e0d1c2b3a4,2023-04-04T08:15:59+00:00,2024-06-29T17:03:14+00:00,Yvonne Newman,41 +y5x6w7v8u9t0s1r2,2021-01-25T18:09:21+00:00,2022-08-16T22:44:51+00:00,Carol Kane,38 +q3p4o5n6m7l8k9j0,2022-06-09T12:53:47+00:00,2023-12-24T01:16:05+00:00,Doris Foster,44 +i1h2g3f4e5d6c7b8,2020-07-03T23:37:02+00:00,2021-05-09T05:52:43+00:00,Joseph Stokes,28 +a9z0y1x2w3v4u5t6,2023-10-10T02:20:15+00:00,2024-03-28T14:33:29+00:00,Steve Williams,31 +s7r8q9p0o1n2m3l4,2021-06-16T13:48:53+00:00,2022-04-22T07:07:19+00:00,James Carey,29 +k5j6i7h8g9f0e1d2,2022-12-27T20:06:38+00:00,2023-08-03T10:25:57+00:00,Kathryn Henry,38 +c3b4a5z6y7x8w9v0,2020-04-20T04:41:24+00:00,2021-02-13T19:14:06+00:00,Christopher Landry,23 +u1t2s3r4q5p6o7n8,2023-05-08T00:58:10+00:00,2024-07-05T03:36:48+00:00,Jennifer Mcgee,62 +m9l0k1j2i3h4g5f6,2021-09-01T06:11:42+00:00,2022-01-26T16:59:23+00:00,Cathy Church,35 +e7d8c9b0a1z2y3x4,2022-02-18T15:24:07+00:00,2023-04-12T00:40:31+00:00,Jose Lopez,41 +w5v6u7t8s9r0q1p2,2020-12-13T09:03:55+00:00,2021-11-06T11:23:16+00:00,William Rose,30 +o3n4m5l6k7j8i9h0,2021-12-13T09:03:55+00:00,2022-11-06T11:23:16+00:00,Charles Hammer,61 From a21e37b054ab948efcd84b019988703f4e5f29cb Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 30 Jul 2025 23:42:01 +1200 Subject: [PATCH 3/6] Add permissions support for CSV --- composer.json | 2 +- composer.lock | 39 ++++++-------- .../Services/Migrations/MigrationsBase.php | 4 +- tests/resources/csv/documents-internals.csv | 52 +++++++++---------- 4 files changed, 44 insertions(+), 53 deletions(-) diff --git a/composer.json b/composer.json index f9e22b5557..31a31af9f2 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "utopia-php/locale": "0.4.*", "utopia-php/logger": "0.6.*", "utopia-php/messaging": "0.18.*", - "utopia-php/migration": "dev-feat-csv-allow-internals as 0.11.2", + "utopia-php/migration": "0.11.*", "utopia-php/orchestration": "0.9.*", "utopia-php/platform": "0.7.*", "utopia-php/pools": "0.8.*", diff --git a/composer.lock b/composer.lock index 83ebd15beb..0089132a38 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2a397a40480933a873d9d8bdca81c78d", + "content-hash": "edbe5912c45e1f467f398541a75a77de", "packages": [ { "name": "adhocore/jwt", @@ -3993,16 +3993,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-feat-csv-allow-internals", + "version": "0.11.3", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "b4a33e84feec22f44e0181d32a7af10a199a82bf" + "reference": "8142d722d8eeec443e6d5df91b69ecf89b86df8e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/b4a33e84feec22f44e0181d32a7af10a199a82bf", - "reference": "b4a33e84feec22f44e0181d32a7af10a199a82bf", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/8142d722d8eeec443e6d5df91b69ecf89b86df8e", + "reference": "8142d722d8eeec443e6d5df91b69ecf89b86df8e", "shasum": "" }, "require": { @@ -4043,9 +4043,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/feat-csv-allow-internals" + "source": "https://github.com/utopia-php/migration/tree/0.13.5" }, - "time": "2025-07-30T04:29:20+00:00" + "time": "2025-07-29T04:15:45+00:00" }, { "name": "utopia-php/orchestration", @@ -4810,16 +4810,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.41.24", + "version": "0.41.26", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "c9ebf8daa25332ca701515d42e8d0c4a7be6a489" + "reference": "5a13191a5a4bdec8fe1b1180ff67f75c4ff6ac0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/c9ebf8daa25332ca701515d42e8d0c4a7be6a489", - "reference": "c9ebf8daa25332ca701515d42e8d0c4a7be6a489", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/5a13191a5a4bdec8fe1b1180ff67f75c4ff6ac0b", + "reference": "5a13191a5a4bdec8fe1b1180ff67f75c4ff6ac0b", "shasum": "" }, "require": { @@ -4855,9 +4855,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.41.24" + "source": "https://github.com/appwrite/sdk-generator/tree/0.41.26" }, - "time": "2025-07-28T06:27:00+00:00" + "time": "2025-07-30T06:53:12+00:00" }, { "name": "doctrine/annotations", @@ -8237,18 +8237,9 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [ - { - "package": "utopia-php/migration", - "version": "dev-feat-csv-allow-internals", - "alias": "0.11.2", - "alias_normalized": "0.11.2.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/migration": 20 - }, + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 124f7d1a37..f20ed2beb6 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -1139,7 +1139,7 @@ trait MigrationsBase $this->assertContains(Resource::TYPE_DOCUMENT, $migration['body']['resources']); $this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']); $this->assertEquals(100, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']); - }, 60_000, 500); + }, 10_000, 500); // all data exists and includes internals, pass. $migration = $this->performCsvMigration( @@ -1166,7 +1166,7 @@ trait MigrationsBase $this->assertContains(Resource::TYPE_DOCUMENT, $migration['body']['resources']); $this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']); $this->assertEquals(25, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']); - }, 60_000, 500); + }, 10_000, 500); return [ 'databaseId' => $databaseId, diff --git a/tests/resources/csv/documents-internals.csv b/tests/resources/csv/documents-internals.csv index c72df314b7..22144ab0b8 100644 --- a/tests/resources/csv/documents-internals.csv +++ b/tests/resources/csv/documents-internals.csv @@ -1,26 +1,26 @@ -$id,$createdAt,$updatedAt,name,age -z1y2x3w4v5u6t7s8,2022-10-23T10:33:01+00:00,2023-03-15T12:00:41+00:00,Diamond Mendez,56 -r9q0p1o2n3m4l5k6,2021-08-11T21:05:13+00:00,2024-01-02T08:45:22+00:00,Michael Huff,20 -j7i8h9g0f1e2d3c4,2020-05-29T14:22:56+00:00,2022-11-30T18:19:33+00:00,Alyssa Rodriguez,37 -b5a6z7y8x9w0v1u2,2023-01-18T03:44:09+00:00,2023-09-07T23:50:17+00:00,Barbara Smith,26 -t3s4r5q6p7o8n9m0,2020-11-02T09:12:45+00:00,2021-07-21T15:30:55+00:00,Evelyn Edwards,54 -l1k2j3i4h5g6f7e8,2022-03-19T19:55:27+00:00,2024-05-14T06:28:11+00:00,Tina Richardson,41 -d9c0b1a2z3y4x5w6,2021-04-07T01:18:34+00:00,2023-06-25T11:47:04+00:00,Joel Hernandez,49 -v7u8t9s0r1q2p3o4,2023-08-22T16:40:18+00:00,2024-02-19T04:09:58+00:00,Zachary Cooper,59 -n5m6l7k8j9i0h1g2,2020-02-12T07:59:01+00:00,2022-09-08T13:21:49+00:00,Brittany Spears,20 -f3e4d5c6b7a8z9y0,2021-12-05T22:33:12+00:00,2023-11-11T02:55:37+00:00,Holly White,47 -x1w2v3u4t5s6r7q8,2022-07-14T05:01:50+00:00,2024-04-01T20:10:26+00:00,Kimberly Barnes,27 -p9o0n1m2l3k4j5i6,2020-09-28T11:27:36+00:00,2021-10-17T09:38:08+00:00,Stephen Miller,53 -h7g8f9e0d1c2b3a4,2023-04-04T08:15:59+00:00,2024-06-29T17:03:14+00:00,Yvonne Newman,41 -y5x6w7v8u9t0s1r2,2021-01-25T18:09:21+00:00,2022-08-16T22:44:51+00:00,Carol Kane,38 -q3p4o5n6m7l8k9j0,2022-06-09T12:53:47+00:00,2023-12-24T01:16:05+00:00,Doris Foster,44 -i1h2g3f4e5d6c7b8,2020-07-03T23:37:02+00:00,2021-05-09T05:52:43+00:00,Joseph Stokes,28 -a9z0y1x2w3v4u5t6,2023-10-10T02:20:15+00:00,2024-03-28T14:33:29+00:00,Steve Williams,31 -s7r8q9p0o1n2m3l4,2021-06-16T13:48:53+00:00,2022-04-22T07:07:19+00:00,James Carey,29 -k5j6i7h8g9f0e1d2,2022-12-27T20:06:38+00:00,2023-08-03T10:25:57+00:00,Kathryn Henry,38 -c3b4a5z6y7x8w9v0,2020-04-20T04:41:24+00:00,2021-02-13T19:14:06+00:00,Christopher Landry,23 -u1t2s3r4q5p6o7n8,2023-05-08T00:58:10+00:00,2024-07-05T03:36:48+00:00,Jennifer Mcgee,62 -m9l0k1j2i3h4g5f6,2021-09-01T06:11:42+00:00,2022-01-26T16:59:23+00:00,Cathy Church,35 -e7d8c9b0a1z2y3x4,2022-02-18T15:24:07+00:00,2023-04-12T00:40:31+00:00,Jose Lopez,41 -w5v6u7t8s9r0q1p2,2020-12-13T09:03:55+00:00,2021-11-06T11:23:16+00:00,William Rose,30 -o3n4m5l6k7j8i9h0,2021-12-13T09:03:55+00:00,2022-11-06T11:23:16+00:00,Charles Hammer,61 +$id,$createdAt,$updatedAt,$permissions,name,age +z1y2x3w4v5u6t7s8,2022-10-23T10:33:01+00:00,2023-03-15T12:00:41+00:00,"read(\"any\"),update(\"user:123\")",Diamond Mendez,56 +r9q0p1o2n3m4l5k6,2021-08-11T21:05:13+00:00,2024-01-02T08:45:22+00:00,"read(\"any\"),update(\"user:456\")",Michael Huff,20 +j7i8h9g0f1e2d3c4,2020-05-29T14:22:56+00:00,2022-11-30T18:19:33+00:00,"read(\"any\")",Alyssa Rodriguez,37 +b5a6z7y8x9w0v1u2,2023-01-18T03:44:09+00:00,2023-09-07T23:50:17+00:00,"read(\"any\")",Barbara Smith,26 +t3s4r5q6p7o8n9m0,2020-11-02T09:12:45+00:00,2021-07-21T15:30:55+00:00,"read(\"any\")",Evelyn Edwards,54 +l1k2j3i4h5g6f7e8,2022-03-19T19:55:27+00:00,2024-05-14T06:28:11+00:00,"read(\"any\")",Tina Richardson,41 +d9c0b1a2z3y4x5w6,2021-04-07T01:18:34+00:00,2023-06-25T11:47:04+00:00,"read(\"any\")",Joel Hernandez,49 +v7u8t9s0r1q2p3o4,2023-08-22T16:40:18+00:00,2024-02-19T04:09:58+00:00,"read(\"any\")",Zachary Cooper,59 +n5m6l7k8j9i0h1g2,2020-02-12T07:59:01+00:00,2022-09-08T13:21:49+00:00,"read(\"any\")",Brittany Spears,20 +f3e4d5c6b7a8z9y0,2021-12-05T22:33:12+00:00,2023-11-11T02:55:37+00:00,"read(\"any\")",Holly White,47 +x1w2v3u4t5s6r7q8,2022-07-14T05:01:50+00:00,2024-04-01T20:10:26+00:00,"read(\"any\")",Kimberly Barnes,27 +p9o0n1m2l3k4j5i6,2020-09-28T11:27:36+00:00,2021-10-17T09:38:08+00:00,"read(\"any\")",Stephen Miller,53 +h7g8f9e0d1c2b3a4,2023-04-04T08:15:59+00:00,2024-06-29T17:03:14+00:00,"read(\"any\")",Yvonne Newman,41 +y5x6w7v8u9t0s1r2,2021-01-25T18:09:21+00:00,2022-08-16T22:44:51+00:00,"read(\"any\")",Carol Kane,38 +q3p4o5n6m7l8k9j0,2022-06-09T12:53:47+00:00,2023-12-24T01:16:05+00:00,"read(\"any\")",Doris Foster,44 +i1h2g3f4e5d6c7b8,2020-07-03T23:37:02+00:00,2021-05-09T05:52:43+00:00,"read(\"any\")",Joseph Stokes,28 +a9z0y1x2w3v4u5t6,2023-10-10T02:20:15+00:00,2024-03-28T14:33:29+00:00,"read(\"any\")",Steve Williams,31 +s7r8q9p0o1n2m3l4,2021-06-16T13:48:53+00:00,2022-04-22T07:07:19+00:00,"read(\"any\")",James Carey,29 +k5j6i7h8g9f0e1d2,2022-12-27T20:06:38+00:00,2023-08-03T10:25:57+00:00,"read(\"any\")",Kathryn Henry,38 +c3b4a5z6y7x8w9v0,2020-04-20T04:41:24+00:00,2021-02-13T19:14:06+00:00,"read(\"any\")",Christopher Landry,23 +u1t2s3r4q5p6o7n8,2023-05-08T00:58:10+00:00,2024-07-05T03:36:48+00:00,"read(\"any\")",Jennifer Mcgee,62 +m9l0k1j2i3h4g5f6,2021-09-01T06:11:42+00:00,2022-01-26T16:59:23+00:00,"read(\"any\")",Cathy Church,35 +e7d8c9b0a1z2y3x4,2022-02-18T15:24:07+00:00,2023-04-12T00:40:31+00:00,"read(\"any\")",Jose Lopez,41 +w5v6u7t8s9r0q1p2,2020-12-13T09:03:55+00:00,2021-11-06T11:23:16+00:00,"read(\"any\")",William Rose,30 +o3n4m5l6k7j8i9h0,2021-12-13T09:03:55+00:00,2022-11-06T11:23:16+00:00,"read(\"any\")",Charles Hammer,61 From 152882d05d4fd70d2d34e2c01e36f49ebe5c2a3e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 30 Jul 2025 23:59:30 +1200 Subject: [PATCH 4/6] Fix ref --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 0089132a38..9b51b272b3 100644 --- a/composer.lock +++ b/composer.lock @@ -3997,12 +3997,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "8142d722d8eeec443e6d5df91b69ecf89b86df8e" + "reference": "fb14e0e35061bfec2656200e3d02a3bdf569a0ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/8142d722d8eeec443e6d5df91b69ecf89b86df8e", - "reference": "8142d722d8eeec443e6d5df91b69ecf89b86df8e", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/fb14e0e35061bfec2656200e3d02a3bdf569a0ac", + "reference": "fb14e0e35061bfec2656200e3d02a3bdf569a0ac", "shasum": "" }, "require": { @@ -4043,9 +4043,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.13.5" + "source": "https://github.com/utopia-php/migration/tree/0.11.3" }, - "time": "2025-07-29T04:15:45+00:00" + "time": "2025-07-30T11:20:31+00:00" }, { "name": "utopia-php/orchestration", From efc21d3dcfbfec578bc359d170ea33afc42faa67 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 31 Jul 2025 00:12:59 +1200 Subject: [PATCH 5/6] Fix tests --- .../Services/Migrations/MigrationsBase.php | 66 +++++-------------- 1 file changed, 15 insertions(+), 51 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index f20ed2beb6..7bcd99885b 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -1141,6 +1141,21 @@ trait MigrationsBase $this->assertEquals(100, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']); }, 10_000, 500); + // get documents count + $documents = $this->client->call(Client::METHOD_GET, '/databases/'.$databaseId.'/collections/'.$collectionId.'/documents', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'queries' => [ + Query::limit(150)->toString() + ] + ]); + + $this->assertEquals(200, $documents['headers']['status-code']); + $this->assertIsArray($documents['body']['documents']); + $this->assertIsNumeric($documents['body']['total']); + $this->assertEquals(100, $documents['body']['total']); + // all data exists and includes internals, pass. $migration = $this->performCsvMigration( [ @@ -1167,57 +1182,6 @@ trait MigrationsBase $this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']); $this->assertEquals(25, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']); }, 10_000, 500); - - return [ - 'databaseId' => $databaseId, - 'collectionId' => $collectionId, - 'migrationId' => $migration['body']['$id'], - ]; - } - - /** - * @depends testCreateCsvMigration - */ - public function testImportSuccessful(array $response): void - { - $databaseId = $response['databaseId']; - $collectionId = $response['collectionId']; - $migrationId = $response['migrationId']; - - $documentsCountInCSV = 100; - - // get migration stats - $this->assertEventually(function () use ($migrationId, $databaseId, $collectionId, $documentsCountInCSV) { - $migration = $this->client->call(Client::METHOD_GET, '/migrations/'.$migrationId, array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); - - $this->assertEquals(200, $migration['headers']['status-code']); - $this->assertEquals('finished', $migration['body']['stage']); - $this->assertEquals('completed', $migration['body']['status']); - $this->assertEquals('CSV', $migration['body']['source']); - $this->assertEquals('Appwrite', $migration['body']['destination']); - $this->assertContains(Resource::TYPE_DOCUMENT, $migration['body']['resources']); - $this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']); - $this->assertEquals($documentsCountInCSV, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']); - }, 60000, 500); - - // get documents count - $documents = $this->client->call(Client::METHOD_GET, '/databases/'.$databaseId.'/collections/'.$collectionId.'/documents', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'queries' => [ - // there should be only 100! - Query::limit(150)->toString() - ] - ]); - - $this->assertEquals(200, $documents['headers']['status-code']); - $this->assertIsArray($documents['body']['documents']); - $this->assertIsNumeric($documents['body']['total']); - $this->assertEquals($documentsCountInCSV, $documents['body']['total']); } private function performCsvMigration(array $body): array From 1ea9aca90f6de7480d780a40dcdb9db9b29325c6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 31 Jul 2025 02:10:29 +1200 Subject: [PATCH 6/6] Fix test --- tests/e2e/Services/Migrations/MigrationsBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 7bcd99885b..5f40662ec3 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -901,7 +901,7 @@ trait MigrationsBase /** * Import documents from a CSV file. */ - public function testCreateCsvMigration(): array + public function testCreateCsvMigration(): void { // Make a database $response = $this->client->call(Client::METHOD_POST, '/databases', [