generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from envor/main
add pgsql
- Loading branch information
Showing
8 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Envor\SchemaMacros\PgSql; | ||
|
||
use Stringable; | ||
|
||
/** | ||
* Create the database if it does not exist | ||
* | ||
* @param string|Stringable $database | ||
* | ||
* @mixin \Illuminate\Database\Schema\MariaDbBuilder | ||
* | ||
* @return bool | ||
*/ | ||
class PgSqlCreateDatabaseIfNotExists | ||
{ | ||
public function __invoke(): callable | ||
{ | ||
return function (string|Stringable $database): bool { | ||
$database = (string) $database; | ||
|
||
/** @var \Illuminate\Database\Schema\PostgresBuilder $this */ | ||
if ($this->databaseExists($database)) { | ||
return false; | ||
} | ||
|
||
return $this->createDatabase($database); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Envor\SchemaMacros\PgSql; | ||
|
||
use Stringable; | ||
|
||
/** | ||
* determine if the database exists | ||
* | ||
* @param string|Stringable $database | ||
* | ||
* @mixin \Illuminate\Database\Schema\MariaDbBuilder | ||
* | ||
* @return bool | ||
*/ | ||
class PgSqlDatabaseExists | ||
{ | ||
public function __invoke(): callable | ||
{ | ||
return function (string|Stringable $database): bool { | ||
$database = (string) $database; | ||
|
||
/** @var \Illuminate\Database\Schema\PostgresBuilder $this */ | ||
return (bool) $this->getConnection()->select("SELECT datname FROM pg_database WHERE datname = '{$database}'"); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,4 @@ | |
|
||
use Exception; | ||
|
||
class UnsupportedDriver extends Exception | ||
{ | ||
} | ||
class UnsupportedDriver extends Exception {} |