Skip to content

Commit

Permalink
Merge pull request #419 from mikeSimonson/refactor-mark-version
Browse files Browse the repository at this point in the history
refactoring the mark version migrated / not migrated code
  • Loading branch information
mikeSimonson committed Jan 13, 2016
2 parents fdcb4e0 + 1de8172 commit 58b4f5c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/Doctrine/DBAL/Migrations/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,26 @@ public function isMigrated()

public function markMigrated()
{
$this->markVersion('up');
}

private function markVersion($direction)
{
if ($direction == 'up') {
$action = 'insert';
} else {
$action = 'delete';
}
$this->configuration->createMigrationTable();
$this->connection->insert(
$this->connection->$action(
$this->configuration->getMigrationsTableName(),
[$this->configuration->getMigrationsColumnName() => $this->version]
);
}

public function markNotMigrated()
{
$this->configuration->createMigrationTable();
$this->connection->delete(
$this->configuration->getMigrationsTableName(),
[$this->configuration->getMigrationsColumnName() => $this->version]
);
$this->markVersion('down');
}

/**
Expand Down

0 comments on commit 58b4f5c

Please sign in to comment.