Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-36: add primary key for migration_table #37

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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