Merge pull request #4450 from appwrite/feat-upgrade-database-0.26
Upgrade to use Database 0.26.0
This commit is contained in:
commit
939f974d19
|
@ -1574,7 +1574,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes')
|
|||
Query::equal('databaseInternalId', [$db->getInternalId()])
|
||||
], 61);
|
||||
|
||||
$limit = 64 - MariaDB::getNumberOfDefaultIndexes();
|
||||
$limit = 64 - MariaDB::getCountOfDefaultIndexes();
|
||||
|
||||
if ($count >= $limit) {
|
||||
throw new Exception(Exception::INDEX_LIMIT_EXCEEDED, 'Index limit exceeded');
|
||||
|
|
15
app/http.php
15
app/http.php
|
@ -91,18 +91,11 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
|
|||
/** @var array $collections */
|
||||
$collections = Config::getParam('collections', []);
|
||||
|
||||
if (!$dbForConsole->exists(App::getEnv('_APP_DB_SCHEMA', 'appwrite'))) {
|
||||
$redis->flushAll();
|
||||
|
||||
Console::success('[Setup] - Creating database: appwrite...');
|
||||
|
||||
$dbForConsole->create(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
|
||||
}
|
||||
|
||||
try {
|
||||
Console::success('[Setup] - Creating metadata table: appwrite...');
|
||||
$dbForConsole->createMetadata();
|
||||
} catch (\Throwable $th) {
|
||||
$redis->flushAll();
|
||||
Console::success('[Setup] - Creating database: appwrite...');
|
||||
$dbForConsole->create(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
|
||||
} catch (\Exception $e) {
|
||||
Console::success('[Setup] - Skip: metadata table already exists');
|
||||
}
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ Database::addFilter(
|
|||
->find('attributes', [
|
||||
Query::equal('collectionInternalId', [$document->getInternalId()]),
|
||||
Query::equal('databaseInternalId', [$document->getAttribute('databaseInternalId')]),
|
||||
Query::limit($database->getAttributeLimit()),
|
||||
Query::limit($database->getLimitForAttributes()),
|
||||
]);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -45,13 +45,13 @@
|
|||
"appwrite/php-runtimes": "0.11.*",
|
||||
"utopia-php/framework": "0.21.*",
|
||||
"utopia-php/logger": "0.3.*",
|
||||
"utopia-php/abuse": "0.13.*",
|
||||
"utopia-php/abuse": "0.14.*",
|
||||
"utopia-php/analytics": "0.2.*",
|
||||
"utopia-php/audit": "0.14.*",
|
||||
"utopia-php/audit": "0.15.*",
|
||||
"utopia-php/cache": "0.6.*",
|
||||
"utopia-php/cli": "0.13.*",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/database": "0.25.*",
|
||||
"utopia-php/database": "0.26.*",
|
||||
"utopia-php/locale": "0.4.*",
|
||||
"utopia-php/registry": "0.5.*",
|
||||
"utopia-php/preloader": "0.2.*",
|
||||
|
|
50
composer.lock
generated
50
composer.lock
generated
|
@ -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": "568151395a8877f87d9bdce048adc2dc",
|
||||
"content-hash": "08fdd139ad1285b02c4b4e555679e7de",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
@ -1741,23 +1741,23 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/abuse",
|
||||
"version": "0.13.1",
|
||||
"version": "0.14.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/abuse.git",
|
||||
"reference": "4c1b8fe742f17158c59550cdfd9074a94bf474ac"
|
||||
"reference": "1a5da248e74c1bfc39bc440fa949de6935acceeb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/4c1b8fe742f17158c59550cdfd9074a94bf474ac",
|
||||
"reference": "4c1b8fe742f17158c59550cdfd9074a94bf474ac",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/1a5da248e74c1bfc39bc440fa949de6935acceeb",
|
||||
"reference": "1a5da248e74c1bfc39bc440fa949de6935acceeb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-pdo": "*",
|
||||
"php": ">=8.0",
|
||||
"utopia-php/database": "0.25.*"
|
||||
"utopia-php/database": "0.26.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.4",
|
||||
|
@ -1789,9 +1789,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/abuse/issues",
|
||||
"source": "https://github.com/utopia-php/abuse/tree/0.13.1"
|
||||
"source": "https://github.com/utopia-php/abuse/tree/0.14.0"
|
||||
},
|
||||
"time": "2022-09-07T16:02:58+00:00"
|
||||
"time": "2022-10-14T11:26:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/analytics",
|
||||
|
@ -1850,22 +1850,22 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/audit",
|
||||
"version": "0.14.1",
|
||||
"version": "0.15.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/audit.git",
|
||||
"reference": "b011224ed9bfef7e5c849938e65619af28f7cf41"
|
||||
"reference": "937ffd13e7a5ac9ad220b329247569ef2a4881d9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/b011224ed9bfef7e5c849938e65619af28f7cf41",
|
||||
"reference": "b011224ed9bfef7e5c849938e65619af28f7cf41",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/937ffd13e7a5ac9ad220b329247569ef2a4881d9",
|
||||
"reference": "937ffd13e7a5ac9ad220b329247569ef2a4881d9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-pdo": "*",
|
||||
"php": ">=8.0",
|
||||
"utopia-php/database": "0.25.*"
|
||||
"utopia-php/database": "0.26.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.3",
|
||||
|
@ -1881,12 +1881,6 @@
|
|||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Eldad Fux",
|
||||
"email": "eldad@appwrite.io"
|
||||
}
|
||||
],
|
||||
"description": "A simple audit library to manage application users logs",
|
||||
"keywords": [
|
||||
"Audit",
|
||||
|
@ -1897,9 +1891,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/audit/issues",
|
||||
"source": "https://github.com/utopia-php/audit/tree/0.14.1"
|
||||
"source": "https://github.com/utopia-php/audit/tree/0.15.0"
|
||||
},
|
||||
"time": "2022-09-07T16:03:16+00:00"
|
||||
"time": "2022-10-14T11:39:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cache",
|
||||
|
@ -2060,16 +2054,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "0.25.5",
|
||||
"version": "0.26.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "6d1c1d46d66553154975a3e8e72d30b5bd2413d9"
|
||||
"reference": "d172af2541137c83a86d066f82f48914b5a3a610"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/6d1c1d46d66553154975a3e8e72d30b5bd2413d9",
|
||||
"reference": "6d1c1d46d66553154975a3e8e72d30b5bd2413d9",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/d172af2541137c83a86d066f82f48914b5a3a610",
|
||||
"reference": "d172af2541137c83a86d066f82f48914b5a3a610",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2118,9 +2112,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/0.25.5"
|
||||
"source": "https://github.com/utopia-php/database/tree/0.26.0"
|
||||
},
|
||||
"time": "2022-09-30T15:01:32+00:00"
|
||||
"time": "2022-10-03T17:12:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/domains",
|
||||
|
@ -5384,5 +5378,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "8.0"
|
||||
},
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.2.0"
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use Utopia\Database\Document;
|
|||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\Roles;
|
||||
|
||||
class Auth
|
||||
{
|
||||
|
@ -427,11 +428,11 @@ class Auth
|
|||
$phoneVerified = $user->getAttribute('phoneVerification', false);
|
||||
|
||||
if ($emailVerified || $phoneVerified) {
|
||||
$roles[] = Role::user($user->getId(), Database::DIMENSION_VERIFIED)->toString();
|
||||
$roles[] = Role::users(Database::DIMENSION_VERIFIED)->toString();
|
||||
$roles[] = Role::user($user->getId(), Roles::DIMENSION_VERIFIED)->toString();
|
||||
$roles[] = Role::users(Roles::DIMENSION_VERIFIED)->toString();
|
||||
} else {
|
||||
$roles[] = Role::user($user->getId(), Database::DIMENSION_UNVERIFIED)->toString();
|
||||
$roles[] = Role::users(Database::DIMENSION_UNVERIFIED)->toString();
|
||||
$roles[] = Role::user($user->getId(), Roles::DIMENSION_UNVERIFIED)->toString();
|
||||
$roles[] = Role::users(Roles::DIMENSION_UNVERIFIED)->toString();
|
||||
}
|
||||
} else {
|
||||
return [Role::guests()->toString()];
|
||||
|
|
|
@ -229,7 +229,7 @@ abstract class Worker
|
|||
throw new \Exception("Project does not exist: {$projectId}");
|
||||
}
|
||||
|
||||
if ($type === self::DATABASE_CONSOLE && !$database->exists($database->getDefaultDatabase(), '_metadata')) {
|
||||
if ($type === self::DATABASE_CONSOLE && !$database->exists($database->getDefaultDatabase(), Database::METADATA)) {
|
||||
throw new \Exception('Console project not ready');
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use Utopia\Database\Role;
|
|||
use Utopia\Database\Validator\Authorization;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Validator\Roles;
|
||||
|
||||
class AuthTest extends TestCase
|
||||
{
|
||||
|
@ -379,8 +380,8 @@ class AuthTest extends TestCase
|
|||
$this->assertCount(11, $roles);
|
||||
$this->assertContains(Role::users()->toString(), $roles);
|
||||
$this->assertContains(Role::user(ID::custom('123'))->toString(), $roles);
|
||||
$this->assertContains(Role::users(Database::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::user(ID::custom('123'), Database::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::users(Roles::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::user(ID::custom('123'), Roles::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::team(ID::custom('abc'))->toString(), $roles);
|
||||
$this->assertContains(Role::team(ID::custom('abc'), 'administrator')->toString(), $roles);
|
||||
$this->assertContains(Role::team(ID::custom('abc'), 'moderator')->toString(), $roles);
|
||||
|
@ -394,15 +395,15 @@ class AuthTest extends TestCase
|
|||
$user['phoneVerification'] = false;
|
||||
|
||||
$roles = Auth::getRoles($user);
|
||||
$this->assertContains(Role::users(Database::DIMENSION_UNVERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::user(ID::custom('123'), Database::DIMENSION_UNVERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::users(Roles::DIMENSION_UNVERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::user(ID::custom('123'), Roles::DIMENSION_UNVERIFIED)->toString(), $roles);
|
||||
|
||||
// Enable single verification type
|
||||
$user['emailVerification'] = true;
|
||||
|
||||
$roles = Auth::getRoles($user);
|
||||
$this->assertContains(Role::users(Database::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::user(ID::custom('123'), Database::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::users(Roles::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::user(ID::custom('123'), Roles::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
}
|
||||
|
||||
public function testPrivilegedUserRoles(): void
|
||||
|
@ -438,8 +439,8 @@ class AuthTest extends TestCase
|
|||
$this->assertCount(7, $roles);
|
||||
$this->assertNotContains(Role::users()->toString(), $roles);
|
||||
$this->assertNotContains(Role::user(ID::custom('123'))->toString(), $roles);
|
||||
$this->assertNotContains(Role::users(Database::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertNotContains(Role::user(ID::custom('123'), Database::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertNotContains(Role::users(Roles::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertNotContains(Role::user(ID::custom('123'), Roles::DIMENSION_VERIFIED)->toString(), $roles);
|
||||
$this->assertContains(Role::team(ID::custom('abc'))->toString(), $roles);
|
||||
$this->assertContains(Role::team(ID::custom('abc'), 'administrator')->toString(), $roles);
|
||||
$this->assertContains(Role::team(ID::custom('abc'), 'moderator')->toString(), $roles);
|
||||
|
|
Loading…
Reference in a new issue