From 253cf9bfc29b6610bee85ce213fad22882551d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Pude=C5=82ek?= Date: Wed, 31 Mar 2021 21:11:46 +0200 Subject: [PATCH 1/3] issue-36: add primary key for migration_table --- src/Database/DblibDatabase.php | 2 +- src/Database/MySqlDatabase.php | 2 +- src/Database/PgsqlDatabase.php | 2 +- src/Database/SqliteDatabase.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Database/DblibDatabase.php b/src/Database/DblibDatabase.php index ff03b7c..d782fa3 100644 --- a/src/Database/DblibDatabase.php +++ b/src/Database/DblibDatabase.php @@ -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(); } diff --git a/src/Database/MySqlDatabase.php b/src/Database/MySqlDatabase.php index 1de031d..297e693 100644 --- a/src/Database/MySqlDatabase.php +++ b/src/Database/MySqlDatabase.php @@ -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(); } diff --git a/src/Database/PgsqlDatabase.php b/src/Database/PgsqlDatabase.php index 533e1ec..f1b18ef 100644 --- a/src/Database/PgsqlDatabase.php +++ b/src/Database/PgsqlDatabase.php @@ -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(); } diff --git a/src/Database/SqliteDatabase.php b/src/Database/SqliteDatabase.php index 080b5d9..7d7fb2d 100644 --- a/src/Database/SqliteDatabase.php +++ b/src/Database/SqliteDatabase.php @@ -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(); } From 7c49a7946277377e2f612735d1e4aaca220ff04b Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Tue, 15 Mar 2022 13:32:28 -0500 Subject: [PATCH 2/3] Fix PHP 8.1 Warnings Issue #41 --- src/Migration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Migration.php b/src/Migration.php index fcc8e41..536867f 100644 --- a/src/Migration.php +++ b/src/Migration.php @@ -184,7 +184,7 @@ public function getFileContent($file) "checksum" => null, "content" => null, ]; - if (!file_exists($file)) { + if (empty($file) || !file_exists($file)) { return $data; } From 276a4544e5f6f0990c877da3b6f53ccb381e3da2 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Tue, 15 Mar 2022 13:32:50 -0500 Subject: [PATCH 3/3] Minor adjustments for PHP 8.1 --- composer.json | 2 +- docker-compose.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 26a4ff2..99cff7b 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "ext-pdo": "*" }, "require-dev": { - "phpunit/phpunit": "5.7.*|7.4.*" + "phpunit/phpunit": "5.7.*|7.4.*|^9.5" }, "autoload": { "psr-4": { diff --git a/docker-compose.yml b/docker-compose.yml index 3ef479a..99a1984 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,7 +30,8 @@ services: mysql: container_name: anydataset_db_mysql - image: mysql:5.7 + image: mysql:8 + command: --default-authentication-plugin=mysql_native_password environment: - MYSQL_ROOT_PASSWORD=password ports: