diff --git a/composer.json b/composer.json index 2e01d86..e499427 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=8.0", - "utopia-php/database": "0.45.*" + "utopia-php/database": "0.46.*" }, "require-dev": { "phpunit/phpunit": "^9.3", diff --git a/composer.lock b/composer.lock index 5a02b0d..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": "44790bd07c37de82d1540fa39093af3d", + "content-hash": "2cd8956883ef667d785f10b28b5fa7f7", "packages": [ { "name": "jean85/pretty-package-versions", @@ -268,16 +268,16 @@ }, { "name": "utopia-php/database", - "version": "0.45.0", + "version": "0.46.0", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "7dfb03e69306c406301b8b9655650ec56f09bf6b" + "reference": "035e6b4a0005ad87aa73beca8714721925ea8f5e" }, "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/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/0.45.0" + "source": "https://github.com/utopia-php/database/tree/0.46.0" }, - "time": "2023-11-01T08:30:19+00:00" + "time": "2023-12-08T16:02:38+00:00" }, { "name": "utopia-php/framework", diff --git a/src/Audit/Audit.php b/src/Audit/Audit.php index e4ed9db..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'); } @@ -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 + } } /** 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);