diff --git a/src/Generators/Webserver/Database/Drivers/PostgreSQL.php b/src/Generators/Webserver/Database/Drivers/PostgreSQL.php index ac4d911f..fc663247 100644 --- a/src/Generators/Webserver/Database/Drivers/PostgreSQL.php +++ b/src/Generators/Webserver/Database/Drivers/PostgreSQL.php @@ -129,6 +129,10 @@ protected function flushConnection(IlluminateConnection $connection, array $conf protected function dropPriviliges(IlluminateConnection $connection, array $config) { + if (config("tenancy.db.tenant-division-mode") === Connection::DIVISION_MODE_SEPARATE_SCHEMA) { + return true; + } + if ($this->userExists($connection, $config['username'])) { return $connection->statement("DROP OWNED BY \"{$config['username']}\""); } diff --git a/src/Generators/Webserver/Database/Drivers/PostgresSchema.php b/src/Generators/Webserver/Database/Drivers/PostgresSchema.php index 76b9ffb5..06cbe937 100644 --- a/src/Generators/Webserver/Database/Drivers/PostgresSchema.php +++ b/src/Generators/Webserver/Database/Drivers/PostgresSchema.php @@ -24,7 +24,7 @@ class PostgresSchema extends PostgreSQL { protected function createDatabase(IlluminateConnection $connection, array $config) { - return $connection->statement("CREATE SCHEMA \"{$config['schema']}\""); + return $connection->statement("CREATE SCHEMA IF NOT EXISTS \"{$config['schema']}\""); } protected function grantPrivileges(IlluminateConnection $connection, array $config) @@ -54,6 +54,6 @@ public function updated(Updated $event, array $config, Connection $connection): protected function dropDatabase(IlluminateConnection $connection, array $config) { - return $connection->statement("DROP SCHEMA IF EXISTS \"{$config['schema']}\""); + return $connection->statement("DROP SCHEMA IF EXISTS \"{$config['schema']}\" CASCADE"); } }