diff --git a/composer.lock b/composer.lock index 5cd409fac6..9b51b272b3 100644 --- a/composer.lock +++ b/composer.lock @@ -3993,16 +3993,16 @@ }, { "name": "utopia-php/migration", - "version": "0.11.2", + "version": "0.11.3", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "00f2b8e9927883f611e4e1ff179fa79e6bb2a12a" + "reference": "fb14e0e35061bfec2656200e3d02a3bdf569a0ac" }, "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/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.11.2" + "source": "https://github.com/utopia-php/migration/tree/0.11.3" }, - "time": "2025-07-29T04:27:20+00:00" + "time": "2025-07-30T11:20:31+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", diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 6bc1f2d427..5f40662ec3 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -901,9 +901,9 @@ trait MigrationsBase /** * Import documents from a CSV file. */ - public function testCreateCsvMigration(): array + public function testCreateCsvMigration(): void { - // make a database + // Make a database $response = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -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', }; @@ -1112,7 +1114,7 @@ trait MigrationsBase ); }, 60000, 500); - // all data exists, pass/ + // all data exists, pass. $migration = $this->performCsvMigration( [ 'endpoint' => 'http://localhost/v1', @@ -1122,32 +1124,8 @@ 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']); - - 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) { + $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'], @@ -1160,8 +1138,8 @@ trait MigrationsBase $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); + $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([ @@ -1169,7 +1147,6 @@ trait MigrationsBase 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ - // there should be only 100! Query::limit(150)->toString() ] ]); @@ -1177,7 +1154,34 @@ trait MigrationsBase $this->assertEquals(200, $documents['headers']['status-code']); $this->assertIsArray($documents['body']['documents']); $this->assertIsNumeric($documents['body']['total']); - $this->assertEquals($documentsCountInCSV, $documents['body']['total']); + $this->assertEquals(100, $documents['body']['total']); + + // 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']); + }, 10_000, 500); } private function performCsvMigration(array $body): array diff --git a/tests/resources/csv/documents-internals.csv b/tests/resources/csv/documents-internals.csv new file mode 100644 index 0000000000..22144ab0b8 --- /dev/null +++ b/tests/resources/csv/documents-internals.csv @@ -0,0 +1,26 @@ +$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