From baf8ba63709d8509f53b6d37304090a5bd059e58 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 13 Aug 2026 13:51:31 +0530 Subject: [PATCH] Include schema in table creation response (#13202) --- .../Databases/Http/Databases/Collections/Create.php | 3 +++ .../Databases/TablesDB/TablesDBColumnsTest.php | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php index b83f0ca615..0db84db7f3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php @@ -258,6 +258,9 @@ class Create extends Action $dbForProject->purgeCachedDocument('database_' . $database->getSequence(), $collection->getId()); $dbForProject->purgeCachedCollection('database_' . $database->getSequence() . '_collection_' . $collection->getSequence()); + // Reload the collection so its subquery filters include the schema created above. + $collection = $authorization->skip(fn () => $dbForProject->getDocument($databaseKey, $collection->getId())); + $queueForEvents ->setContext('database', $database) ->setParam('databaseId', $databaseId) diff --git a/tests/e2e/Services/Databases/TablesDB/TablesDBColumnsTest.php b/tests/e2e/Services/Databases/TablesDB/TablesDBColumnsTest.php index 6235a8bfcb..a7d65488ab 100644 --- a/tests/e2e/Services/Databases/TablesDB/TablesDBColumnsTest.php +++ b/tests/e2e/Services/Databases/TablesDB/TablesDBColumnsTest.php @@ -55,9 +55,22 @@ final class TablesDBColumnsTest extends Scope ['key' => 'address', 'type' => 'ip'], ['key' => 'status', 'type' => 'enum', 'elements' => ['on', 'off'], 'default' => 'on'], ], + 'indexes' => [ + ['key' => 'slug_unique', 'type' => 'unique', 'attributes' => ['slug']], + ], ]); $this->assertEquals(201, $table['headers']['status-code']); + $this->assertCount(9, $table['body']['columns']); + $columnKeys = array_column($table['body']['columns'], 'key'); + sort($columnKeys); + $this->assertEquals( + ['address', 'archive', 'email', 'modulePath', 'slug', 'status', 'summary', 'title', 'website'], + $columnKeys, + ); + $this->assertCount(1, $table['body']['indexes']); + $this->assertEquals('slug_unique', $table['body']['indexes'][0]['key']); + $this->assertEquals('available', $table['body']['indexes'][0]['status']); $tableId = $table['body']['$id']; $columns = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/columns', $headers);