From f23351d44c1f9c5481730a8d7e284d1954eef2ba Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 22 Nov 2023 22:44:35 +1300 Subject: [PATCH 1/4] Ignore duplicate collection for shared table isolation modes --- composer.json | 2 +- composer.lock | 27 ++++++++++++++++++--------- src/Audit/Audit.php | 6 +++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 2e01d86..a7a2e99 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=8.0", - "utopia-php/database": "0.45.*" + "utopia-php/database": "dev-feat-isolation-mode as 0.45.0" }, "require-dev": { "phpunit/phpunit": "^9.3", diff --git a/composer.lock b/composer.lock index 5a02b0d..4cfcd9e 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": "44790bd07c37de82d1540fa39093af3d", + "content-hash": "95d6c177f2b400532ca2c3c37af6c72b", "packages": [ { "name": "jean85/pretty-package-versions", @@ -268,16 +268,16 @@ }, { "name": "utopia-php/database", - "version": "0.45.0", + "version": "dev-feat-isolation-mode", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "7dfb03e69306c406301b8b9655650ec56f09bf6b" + "reference": "b7bcc9b373242a9e494b0b7bbf78dfa54333727c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/7dfb03e69306c406301b8b9655650ec56f09bf6b", - "reference": "7dfb03e69306c406301b8b9655650ec56f09bf6b", + "url": "https://api.github.com/repos/utopia-php/database/zipball/b7bcc9b373242a9e494b0b7bbf78dfa54333727c", + "reference": "b7bcc9b373242a9e494b0b7bbf78dfa54333727c", "shasum": "" }, "require": { @@ -318,9 +318,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.45.0" + "source": "https://github.com/utopia-php/database/tree/feat-isolation-mode" }, - "time": "2023-11-01T08:30:19+00:00" + "time": "2023-11-22T07:58:21+00:00" }, { "name": "utopia-php/framework", @@ -2290,9 +2290,18 @@ "time": "2021-07-28T10:34:58+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-feat-isolation-mode", + "alias": "0.45.0", + "alias_normalized": "0.45.0.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Audit/Audit.php b/src/Audit/Audit.php index e4ed9db..9809deb 100644 --- a/src/Audit/Audit.php +++ b/src/Audit/Audit.php @@ -144,7 +144,11 @@ public function setup(): void ]), ]; - $this->db->createCollection(Audit::COLLECTION, $attributes, $indexes); + try { + $this->db->createCollection(Audit::COLLECTION, $attributes, $indexes); + } catch (DuplicateException) { + // Collection already exists + } } /** From 97963393f2786afa5136f0993598b2cf5fd1ed08 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 22 Nov 2023 22:46:30 +1300 Subject: [PATCH 2/4] Fix renamed method usage --- src/Audit/Audit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Audit/Audit.php b/src/Audit/Audit.php index 9809deb..048d2c4 100644 --- a/src/Audit/Audit.php +++ b/src/Audit/Audit.php @@ -33,7 +33,7 @@ public function __construct(Database $db) */ public function setup(): void { - if (! $this->db->exists($this->db->getDefaultDatabase())) { + if (! $this->db->exists($this->db->getDatabase())) { throw new Exception('You need to create the database before running Audit setup'); } From b561fa872c60e28afda02b4428ad5a2444099c44 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 22 Nov 2023 22:49:57 +1300 Subject: [PATCH 3/4] Fix test --- tests/Audit/AuditTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Audit/AuditTest.php b/tests/Audit/AuditTest.php index eb1b570..0c81547 100644 --- a/tests/Audit/AuditTest.php +++ b/tests/Audit/AuditTest.php @@ -25,7 +25,7 @@ public function setUp(): void $pdo = new PDO("mysql:host={$dbHost};port={$dbPort};charset=utf8mb4", $dbUser, $dbPass, MariaDB::getPdoAttributes()); $cache = new Cache(new NoCache()); $database = new Database(new MariaDB($pdo), $cache); - $database->setDefaultDatabase('utopiaTests'); + $database->setDatabase('utopiaTests'); $database->setNamespace('namespace'); $this->audit = new Audit($database); From ea34a64ff91ce43a06c385ba296465a2b3778e3b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 8 Dec 2023 17:29:47 +0100 Subject: [PATCH 4/4] Update database --- composer.json | 2 +- composer.lock | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index a7a2e99..e499427 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=8.0", - "utopia-php/database": "dev-feat-isolation-mode as 0.45.0" + "utopia-php/database": "0.46.*" }, "require-dev": { "phpunit/phpunit": "^9.3", diff --git a/composer.lock b/composer.lock index 4cfcd9e..6c8225a 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": "95d6c177f2b400532ca2c3c37af6c72b", + "content-hash": "2cd8956883ef667d785f10b28b5fa7f7", "packages": [ { "name": "jean85/pretty-package-versions", @@ -268,16 +268,16 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-isolation-mode", + "version": "0.46.0", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "b7bcc9b373242a9e494b0b7bbf78dfa54333727c" + "reference": "035e6b4a0005ad87aa73beca8714721925ea8f5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/b7bcc9b373242a9e494b0b7bbf78dfa54333727c", - "reference": "b7bcc9b373242a9e494b0b7bbf78dfa54333727c", + "url": "https://api.github.com/repos/utopia-php/database/zipball/035e6b4a0005ad87aa73beca8714721925ea8f5e", + "reference": "035e6b4a0005ad87aa73beca8714721925ea8f5e", "shasum": "" }, "require": { @@ -318,9 +318,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/feat-isolation-mode" + "source": "https://github.com/utopia-php/database/tree/0.46.0" }, - "time": "2023-11-22T07:58:21+00:00" + "time": "2023-12-08T16:02:38+00:00" }, { "name": "utopia-php/framework", @@ -2290,18 +2290,9 @@ "time": "2021-07-28T10:34:58+00:00" } ], - "aliases": [ - { - "package": "utopia-php/database", - "version": "dev-feat-isolation-mode", - "alias": "0.45.0", - "alias_normalized": "0.45.0.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/database": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": {