Skip to content

Commit

Permalink
Merge pull request #39 from Recras/migration-table-creation
Browse files Browse the repository at this point in the history
Don't try to automagically create migration table all the time
  • Loading branch information
Ugoku authored Nov 30, 2020
2 parents bc73264 + e3683a6 commit c14c57b
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions lib/Doctrine/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ public function setCurrentVersion($number)
*/
public function getCurrentVersion()
{
$this->_createMigrationTable();

$result = $this->_connection->fetchColumn("SELECT version FROM " . $this->_migrationTableName);

return isset($result[0]) ? $result[0]:0;
Expand All @@ -248,8 +246,6 @@ public function getCurrentVersion()
*/
public function hasMigrated()
{
$this->_createMigrationTable();

$result = $this->_connection->fetchColumn("SELECT version FROM " . $this->_migrationTableName);

return isset($result[0]) ? true:false;
Expand Down Expand Up @@ -309,8 +305,6 @@ public function migrate($to = null, $dryRun = false)
{
$this->clearErrors();

$this->_createMigrationTable();

$this->_connection->beginTransaction();

try {
Expand Down Expand Up @@ -526,28 +520,4 @@ protected function _doMigrateStep($direction, $num)
$this->addError($e);
}
}

/**
* Create the migration table and return true. If it already exists it will
* silence the exception and return false
*
* @return boolean $created Whether or not the table was created. Exceptions
* are silenced when table already exists
*/
protected function _createMigrationTable()
{
if ($this->_migrationTableCreated) {
return true;
}

$this->_migrationTableCreated = true;

try {
$this->_connection->export->createTable($this->_migrationTableName, array('version' => array('type' => 'integer', 'size' => 11)));

return true;
} catch(Exception $e) {
return false;
}
}
}
}

0 comments on commit c14c57b

Please sign in to comment.