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: 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 55423e1..189f00e 100644 --- a/src/Database/SqliteDatabase.php +++ b/src/Database/SqliteDatabase.php @@ -41,7 +41,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/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; }