Skip to content

Commit

Permalink
issue-36: add primary key for migration_table
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnpdlk committed Mar 31, 2021
1 parent a506e24 commit 253cf9b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Database/DblibDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function createTableIfNotExists($database, $createTable)
public function createVersion()
{
$database = preg_replace('~^/~', '', $this->getDbDriver()->getUri()->getPath());
$createTable = 'CREATE TABLE ' . $this->getMigrationTable() . ' (version int, status varchar(20))';
$createTable = 'CREATE TABLE ' . $this->getMigrationTable() . ' (version int, status varchar(20), PRIMARY KEY (version))';
$this->createTableIfNotExists($database, $createTable);
$this->checkExistsVersion();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database/MySqlDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function dropDatabase()
*/
public function createVersion()
{
$this->getDbDriver()->execute('CREATE TABLE IF NOT EXISTS ' . $this->getMigrationTable() . ' (version int, status varchar(20))');
$this->getDbDriver()->execute('CREATE TABLE IF NOT EXISTS ' . $this->getMigrationTable() . ' (version int, status varchar(20), PRIMARY KEY (version))');
$this->checkExistsVersion();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Database/PgsqlDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function dropDatabase()
*/
public function createVersion()
{
$this->getDbDriver()->execute('CREATE TABLE IF NOT EXISTS ' . $this->getMigrationTable() . ' (version int, status varchar(20))');
$this->getDbDriver()->execute('CREATE TABLE IF NOT EXISTS ' . $this->getMigrationTable() . ' (version int, status varchar(20), PRIMARY KEY (version))');
$this->checkExistsVersion();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Database/SqliteDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function dropDatabase()
*/
public function createVersion()
{
$this->getDbDriver()->execute('CREATE TABLE IF NOT EXISTS ' . $this->getMigrationTable() . ' (version int, status varchar(20))');
$this->getDbDriver()->execute('CREATE TABLE IF NOT EXISTS ' . $this->getMigrationTable() . ' (version int, status varchar(20), PRIMARY KEY (version))');
$this->checkExistsVersion();
}

Expand Down

0 comments on commit 253cf9b

Please sign in to comment.