Skip to content

Database aliases, new terminologies and a migration to modules #9693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 122 commits into
base: 1.7.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
814be66
update: use new terminologies on path params and local variables.
ItzNotABug Apr 26, 2025
4f1f9bb
add: filter for latest changes.
ItzNotABug Apr 26, 2025
2171544
fix|update: database tests for new error messages.
ItzNotABug Apr 26, 2025
89ce5a6
add: todo.
ItzNotABug Apr 26, 2025
949f585
change: events system.
ItzNotABug Apr 27, 2025
f94ecc8
fix: tests as per new events system.
ItzNotABug Apr 27, 2025
9cccd89
fix: graphql tests.
ItzNotABug Apr 27, 2025
9bf1fdc
fix: graphql tests.
ItzNotABug Apr 27, 2025
7ffd5cf
fix: graphql tests, again.
ItzNotABug Apr 27, 2025
b3b9961
init: move to module structure for database; start with columns.
ItzNotABug May 4, 2025
9c1ec6f
update: move the init hook.
ItzNotABug May 4, 2025
1945a64
update: move DB ops to module.
ItzNotABug May 4, 2025
8efc154
update: move Table ops to module.
ItzNotABug May 4, 2025
3271ef5
update: move Index ops to module.
ItzNotABug May 4, 2025
76785d5
fix: imports, lint.
ItzNotABug May 4, 2025
fd7801f
add: register index and table modules.
ItzNotABug May 4, 2025
286c695
add: move and register row modules.
ItzNotABug May 4, 2025
4cd8f49
add: usage.
ItzNotABug May 4, 2025
57a9218
remove: database controller 👋
ItzNotABug May 4, 2025
ad16bd2
add: database module to platform registry.
ItzNotABug May 4, 2025
6fac164
update: keep message same.
ItzNotABug May 4, 2025
c3d3665
Merge branch '1.7.x' into database-aliases
ItzNotABug May 4, 2025
2554adb
update: error messages.
ItzNotABug May 4, 2025
e0a4c69
fix: `float` column creation!
ItzNotABug May 4, 2025
d184d1c
fix: lint!
ItzNotABug May 4, 2025
8504fbc
update: `collection` response model to `table`.
ItzNotABug May 5, 2025
675d404
update: `attribute*` response model to `column*`.
ItzNotABug May 5, 2025
7a53680
update: `document` response model to `row`; refactor: old collection …
ItzNotABug May 5, 2025
cabf325
update: return keys.
ItzNotABug May 5, 2025
6cb4439
update: services.
ItzNotABug May 5, 2025
bdfab30
Merge branch 'database-aliases' into response-filters-for-databases
ItzNotABug May 5, 2025
71ad9c2
fix: response modals, mappings, filters.
ItzNotABug May 5, 2025
d30fd56
patch: index module to use/specify `columns` instead of `attributes`.
ItzNotABug May 5, 2025
e2202e9
remove: old attributes anyway.
ItzNotABug May 5, 2025
75c9db8
update: tests to use the 1.7.x changes on databases.
ItzNotABug May 5, 2025
37fb34a
wip: events compat based on version.
ItzNotABug May 5, 2025
b905af9
fix: project usage `documents` to `rows`.
ItzNotABug May 5, 2025
67a8f52
fix: project and general usage tests.
ItzNotABug May 5, 2025
565e6b2
fix: migrations test <> csv imports.
ItzNotABug May 5, 2025
56077d5
fix: graphql tests.
ItzNotABug May 6, 2025
9e1105b
update: tests.
ItzNotABug May 6, 2025
253c428
remove: filter.
ItzNotABug May 6, 2025
3a8f097
fix: realtime channels; update: row model.
ItzNotABug May 6, 2025
86d195c
update: request, response filters.
ItzNotABug May 6, 2025
9ec897f
fix: filtering
ItzNotABug May 6, 2025
b1735ef
remove: aliasing filter.
ItzNotABug May 6, 2025
a0ffcd5
Merge branch 'response-filters-for-databases' into events-compatibility
ItzNotABug May 6, 2025
d70d001
add: backported channels.
ItzNotABug May 6, 2025
59e5ce0
update: `collections` <> `tables` errors.
ItzNotABug May 6, 2025
6e8dbfc
update: `documents` <> `rows` errors.
ItzNotABug May 6, 2025
7a52ace
update: `attributes` <> `columns` errors.
ItzNotABug May 6, 2025
6eb1c3a
update: rename remaining variables.
ItzNotABug May 6, 2025
3e813f6
update: change filter name for collections <> tables.
ItzNotABug May 6, 2025
ed9306e
update: change filter name for attributes <> columns.
ItzNotABug May 6, 2025
9a45a0f
Merge branch 'response-filters-for-databases' into events-compatibility
ItzNotABug May 6, 2025
80915fc
Merge branch 'events-compatibility' into update-exceptions
ItzNotABug May 6, 2025
ee117b8
manage: events and channels.
ItzNotABug May 7, 2025
0261509
Merge pull request #9722 from appwrite/events-compatibility
ItzNotABug May 7, 2025
46ccf6f
update: re-add legacy models; remove: filters.
ItzNotABug May 7, 2025
7f023f2
update: keep both tables and collections api errors.
ItzNotABug May 7, 2025
0266376
Merge branch 'response-filters-for-databases' into update-exceptions
ItzNotABug May 7, 2025
28a74e6
Merge pull request #9728 from appwrite/update-exceptions
ItzNotABug May 7, 2025
8610687
update: events schema, response models for database usages.
ItzNotABug May 7, 2025
04386ee
Merge pull request #9720 from appwrite/response-filters-for-databases
ItzNotABug May 7, 2025
f2f23be
update: events, errors, realtime.
ItzNotABug May 7, 2025
6d1afea
misc.
ItzNotABug May 7, 2025
0f94b80
update: abstraction over table and collection apis.
ItzNotABug May 7, 2025
b534d38
Merge branch '1.7.x' into database-aliases
ItzNotABug May 7, 2025
69cc4f0
update: handle the context logic, use defaults.
ItzNotABug May 7, 2025
bc8a38b
update: abstraction over attribute and column apis [WIP].
ItzNotABug May 7, 2025
6493759
Merge remote-tracking branch 'origin/database-aliases' into database-…
ItzNotABug May 7, 2025
b55521e
update: address minor comments by `coderabbitai`.
ItzNotABug May 8, 2025
fc456b4
update: abstraction over attribute and column apis.
ItzNotABug May 8, 2025
cb64484
update: abstraction over document and row apis.
ItzNotABug May 8, 2025
96b8969
update: use `abstract` for `getResponseModel`.
ItzNotABug May 8, 2025
da70da9
update: use nested directory structure.
ItzNotABug May 8, 2025
fe693a9
add: indexes api to tables.
ItzNotABug May 8, 2025
6fba4a5
update: sdk namespaces.
ItzNotABug May 8, 2025
97d1a53
fix: missing path :\
ItzNotABug May 8, 2025
d7023b5
fix: namespaces.
ItzNotABug May 8, 2025
eafa9bb
fix: namespaces, again.
ItzNotABug May 8, 2025
c4a26fb
fix: another pesky sdk namespace 🤨.
ItzNotABug May 8, 2025
4e83fc8
update: split service registrations into smaller registries.
ItzNotABug May 8, 2025
44a5fef
misc: name fixes.
ItzNotABug May 8, 2025
8006c9d
misc: fixes.
ItzNotABug May 8, 2025
36e6617
update: the usage modals.
ItzNotABug May 8, 2025
5c07174
update: the usage model.
ItzNotABug May 8, 2025
c5074fd
update: move around tests.
ItzNotABug May 8, 2025
2d74765
update: fix exception.
ItzNotABug May 8, 2025
0ecd97d
fix: wrong param.
ItzNotABug May 9, 2025
ef30e82
misc: changes to the databases worker.
ItzNotABug May 9, 2025
938b376
fix: var ref.
ItzNotABug May 9, 2025
65dbebd
misc: fix error types.
ItzNotABug May 9, 2025
a8dc5c3
add: table tests to usage.
ItzNotABug May 9, 2025
a807dd9
fix: realtime events.
ItzNotABug May 9, 2025
f10be55
update: short the callbacks.
ItzNotABug May 9, 2025
d3f1c4f
revert: tests to `collections` API.
ItzNotABug May 9, 2025
94fbf19
fix|add: tables api tests to realtime.
ItzNotABug May 9, 2025
1756acd
fix: realtime channel count.
ItzNotABug May 9, 2025
f16ba8d
add: table api tests.
ItzNotABug May 9, 2025
241779e
add: table api tests to abuse.
ItzNotABug May 9, 2025
d5e94a5
revert: graphql tests for collections api.
ItzNotABug May 9, 2025
c542ba0
patch: graphql tests <> collections.
ItzNotABug May 9, 2025
a067b77
update: model; add|update: graphql tests [wip].
ItzNotABug May 9, 2025
e1c5b3f
Merge branch '1.7.x' into database-aliases
ItzNotABug May 10, 2025
d1ae065
update: realtime events logic.
ItzNotABug May 10, 2025
02af05b
fix: endpoint in abuse test.
ItzNotABug May 10, 2025
594f859
update: database server test for graphql <> tables api.
ItzNotABug May 10, 2025
68994f2
fix: graphql tests.
ItzNotABug May 10, 2025
5022a05
update: test coverage for databases.
ItzNotABug May 10, 2025
fbe2609
update: simplify setting events context param.
ItzNotABug May 10, 2025
5dca1ff
update: fix test variable.
ItzNotABug May 10, 2025
ba26eae
Merge remote-tracking branch 'origin/database-aliases' into database-…
ItzNotABug May 10, 2025
45370f9
add: table apis to webhook tests.
ItzNotABug May 10, 2025
afa8341
add: table apis to webhook custom server tests.
ItzNotABug May 10, 2025
6bdfe3b
address naming comments.
ItzNotABug May 10, 2025
15e0385
update: exception name.
ItzNotABug May 10, 2025
9ba29d4
update: var name.
ItzNotABug May 10, 2025
e50d7df
fix: audits event.
ItzNotABug May 10, 2025
63d591e
fix: method name.
ItzNotABug May 10, 2025
b0d9215
fix: abuse tests!
ItzNotABug May 10, 2025
087ccfe
remove: todo.
ItzNotABug May 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add: table api tests.
  • Loading branch information
ItzNotABug committed May 9, 2025
commit f16ba8dee3d8c0e3924b9f13c25ee574d59693d3
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ jobs:
Avatars,
Console,
Databases/Collections,
Databases/Tables,
Functions,
FunctionsSchedule,
GraphQL,
Expand Down Expand Up @@ -214,6 +215,7 @@ jobs:
Avatars,
Console,
Databases/Collections,
Databases/Tables,
Functions,
FunctionsSchedule,
GraphQL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public function action(string $databaseId, string $documentId, string $collectio
throw new Exception($this->getParentNotFoundException());
}


// Add $collectionId and $databaseId for all documents
$processDocument = function (Document $table, Document $document) use (&$processDocument, $dbForProject, $database) {
$document->setAttribute('$databaseId', $database->getId());
Expand Down
4,919 changes: 4,919 additions & 0 deletions tests/e2e/Services/Databases/Tables/DatabasesBase.php

Large diffs are not rendered by default.

336 changes: 336 additions & 0 deletions tests/e2e/Services/Databases/Tables/DatabasesConsoleClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
<?php

namespace Tests\E2E\Services\Databases\Tables;

use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideConsole;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Query;

class DatabasesConsoleClientTest extends Scope
{
use ProjectCustom;
use SideConsole;

public function testCreateCollection(): array
{
$database = $this->client->call(Client::METHOD_POST, '/databases', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'databaseId' => ID::unique(),
'name' => 'invalidDocumentDatabase',
]);
$this->assertEquals(201, $database['headers']['status-code']);
$this->assertEquals('invalidDocumentDatabase', $database['body']['name']);
$this->assertTrue($database['body']['enabled']);

$databaseId = $database['body']['$id'];

/**
* Test for SUCCESS
*/
$movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'tableId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
'documentSecurity' => true,
]);

$this->assertEquals(201, $movies['headers']['status-code']);
$this->assertEquals($movies['body']['name'], 'Movies');

/**
* Test when database is disabled but can still create collections
*/
$database = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'invalidDocumentDatabase Updated',
'enabled' => false,
]);

$this->assertFalse($database['body']['enabled']);

$tvShows = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/tables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'tableId' => ID::unique(),
'name' => 'TvShows',
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
'documentSecurity' => true,
]);

/**
* Test when collection is disabled but can still modify collections
*/
$database = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/tables/' . $movies['body']['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Movies',
'enabled' => false,
]);

$this->assertEquals(201, $tvShows['headers']['status-code']);
$this->assertEquals($tvShows['body']['name'], 'TvShows');

return ['moviesId' => $movies['body']['$id'], 'databaseId' => $databaseId, 'tvShowsId' => $tvShows['body']['$id']];
}

/**
* @depends testCreateCollection
* @param array $data
* @throws \Exception
*/
public function testListCollection(array $data)
{
/**
* Test when database is disabled but can still call list collections
*/
$databaseId = $data['databaseId'];

$tables = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()));

$this->assertEquals(200, $tables['headers']['status-code']);
$this->assertEquals(2, $tables['body']['total']);
}

/**
* @depends testCreateCollection
* @param array $data
* @throws \Exception
*/
public function testGetCollection(array $data)
{
$databaseId = $data['databaseId'];
$moviesCollectionId = $data['moviesId'];

/**
* Test when database and collection are disabled but can still call get collection
*/
$table = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $moviesCollectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));

$this->assertEquals(200, $table['headers']['status-code']);
$this->assertEquals('Movies', $table['body']['name']);
$this->assertEquals($moviesCollectionId, $table['body']['$id']);
$this->assertFalse($table['body']['enabled']);
}

/**
* @depends testCreateCollection
* @param array $data
* @throws \Exception
* @throws \Exception
*/
public function testUpdateCollection(array $data)
{
$databaseId = $data['databaseId'];
$moviesCollectionId = $data['moviesId'];

/**
* Test When database and collection are disabled but can still call update collection
*/
$table = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/tables/' . $moviesCollectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Movies Updated',
'enabled' => false
]);

$this->assertEquals(200, $table['headers']['status-code']);
$this->assertEquals('Movies Updated', $table['body']['name']);
$this->assertEquals($moviesCollectionId, $table['body']['$id']);
$this->assertFalse($table['body']['enabled']);
}

/**
* @depends testCreateCollection
* @param array $data
* @throws \Exception
* @throws \Exception
*/
public function testDeleteCollection(array $data)
{
$databaseId = $data['databaseId'];
$tvShowsId = $data['tvShowsId'];

/**
* Test when database and collection are disabled but can still call delete collection
*/
$response = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/tables/' . $tvShowsId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));

$this->assertEquals(204, $response['headers']['status-code']);
$this->assertEquals($response['body'], "");
}

/**
* @depends testCreateCollection
*/
public function testGetDatabaseUsage(array $data)
{
$databaseId = $data['databaseId'];
/**
* Test for FAILURE
*/

$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/usage', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()), [
'range' => '32h'
]);

$this->assertEquals(400, $response['headers']['status-code']);

/**
* Test for SUCCESS
*/

$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/usage', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()), [
'range' => '24h'
]);



$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(15, count($response['body']));
$this->assertEquals('24h', $response['body']['range']);
$this->assertIsNumeric($response['body']['rowsTotal']);
$this->assertIsNumeric($response['body']['tablesTotal']);
$this->assertIsArray($response['body']['tables']);
$this->assertIsArray($response['body']['rows']);
}


/**
* @depends testCreateCollection
*/
public function testGetCollectionUsage(array $data)
{
$databaseId = $data['databaseId'];
/**
* Test for FAILURE
*/

$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/usage', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()), [
'range' => '32h'
]);

$this->assertEquals(400, $response['headers']['status-code']);

$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/randomCollectionId/usage', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()), [
'range' => '24h'
]);

$this->assertEquals(404, $response['headers']['status-code']);

/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/usage', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()), [
'range' => '24h'
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(3, count($response['body']));
$this->assertEquals('24h', $response['body']['range']);
$this->assertIsNumeric($response['body']['rowsTotal']);
$this->assertIsArray($response['body']['rows']);
}

/**
* @depends testCreateCollection
* @throws \Utopia\Database\Exception\Query
*/
public function testGetCollectionLogs(array $data)
{
$databaseId = $data['databaseId'];
/**
* Test for SUCCESS
*/
$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));

$this->assertEquals(200, $logs['headers']['status-code']);
$this->assertIsArray($logs['body']['logs']);
$this->assertIsNumeric($logs['body']['total']);

$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => [Query::limit(1)->toString()]
]);

$this->assertEquals(200, $logs['headers']['status-code']);
$this->assertIsArray($logs['body']['logs']);
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
$this->assertIsNumeric($logs['body']['total']);

$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => [Query::offset(1)->toString()]
]);

$this->assertEquals(200, $logs['headers']['status-code']);
$this->assertIsArray($logs['body']['logs']);
$this->assertIsNumeric($logs['body']['total']);

$logs = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/tables/' . $data['moviesId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => [Query::offset(1)->toString(), Query::limit(1)->toString()]
]);

$this->assertEquals(200, $logs['headers']['status-code']);
$this->assertIsArray($logs['body']['logs']);
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
$this->assertIsNumeric($logs['body']['total']);
}
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy