-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,9 +32,6 @@ class PgSqlDriver extends BaseDriver implements IDriver | |
/** @var string */ | ||
protected $primarySequence; | ||
|
||
/** @var string */ | ||
protected $lockTableName; | ||
|
||
|
||
/** | ||
* @param IDbal $dbal | ||
|
@@ -47,7 +44,6 @@ public function __construct(IDbal $dbal, $tableName = 'migrations', $schema = 'p | |
$this->schema = $dbal->escapeIdentifier($schema); | ||
$this->schemaStr = $dbal->escapeString($schema); | ||
$this->primarySequence = $this->dbal->escapeString($tableName . '_id_seq'); | ||
$this->lockTableName = $dbal->escapeIdentifier($tableName . '_lock'); | ||
} | ||
|
||
|
||
|
@@ -84,18 +80,8 @@ public function rollbackTransaction() | |
public function lock() | ||
{ | ||
try { | ||
$schemaExist = (bool) $this->dbal->query(" | ||
SELECT schema_name | ||
FROM information_schema.schemata | ||
WHERE schema_name = {$this->schemaStr} | ||
"); | ||
|
||
if (!$schemaExist) { | ||
// CREATE SCHEMA IF NOT EXIST is not available in PostgreSQL < 9.3 | ||
$this->dbal->exec("CREATE SCHEMA {$this->schema}"); | ||
} | ||
|
||
$this->dbal->exec("CREATE TABLE {$this->schema}.{$this->lockTableName} (\"foo\" INT)"); | ||
$this->dbal->exec('SELECT pg_advisory_lock(-2099128779216184107)'); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JanTvrdik
Author
Member
|
||
|
||
} catch (\Exception $e) { | ||
throw new LockException('Unable to acquire a lock.', NULL, $e); | ||
} | ||
|
@@ -105,7 +91,8 @@ public function lock() | |
public function unlock() | ||
{ | ||
try { | ||
$this->dbal->exec("DROP TABLE IF EXISTS {$this->schema}.{$this->lockTableName}"); | ||
$this->dbal->exec('SELECT pg_advisory_unlock(-2099128779216184107)'); | ||
|
||
} catch (\Exception $e) { | ||
throw new LockException('Unable to release a lock.', NULL, $e); | ||
} | ||
|
some description should be added with the weird number explanation! @JanTvrdik (please add it)