From 5e4591284bcf1bd2ef9dc829522910f6d88da1b4 Mon Sep 17 00:00:00 2001 From: Oskar Kregar Date: Tue, 20 Dec 2022 13:55:44 +0100 Subject: [PATCH 1/2] add fix for mariadb virtual column creation --- src/Phinx/Db/Adapter/MysqlAdapter.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Phinx/Db/Adapter/MysqlAdapter.php b/src/Phinx/Db/Adapter/MysqlAdapter.php index f983dfbcc..8397d7fc5 100644 --- a/src/Phinx/Db/Adapter/MysqlAdapter.php +++ b/src/Phinx/Db/Adapter/MysqlAdapter.php @@ -1362,7 +1362,10 @@ protected function getColumnSqlDefinition(Column $column): string $def .= $column->getEncoding() ? ' CHARACTER SET ' . $column->getEncoding() : ''; $def .= $column->getCollation() ? ' COLLATE ' . $column->getCollation() : ''; $def .= !$column->isSigned() && isset($this->signedColumnTypes[$column->getType()]) ? ' unsigned' : ''; - $def .= $column->isNull() ? ' NULL' : ' NOT NULL'; + + if (!($column->getType() instanceof Literal) || strpos($this->getConnection()->getAttribute(PDO::ATTR_SERVER_VERSION), "MariaDB") === false) { + $def .= $column->isNull() ? ' NULL' : ' NOT NULL'; + } if ( version_compare($this->getAttribute(\PDO::ATTR_SERVER_VERSION), '8', '>=') From 77604a83646db602864188b0dfe4a1cc0ccddec8 Mon Sep 17 00:00:00 2001 From: Oskar Kregar Date: Tue, 20 Dec 2022 14:12:58 +0100 Subject: [PATCH 2/2] fix to single quotes simple string --- src/Phinx/Db/Adapter/MysqlAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Phinx/Db/Adapter/MysqlAdapter.php b/src/Phinx/Db/Adapter/MysqlAdapter.php index 8397d7fc5..e5f4cba78 100644 --- a/src/Phinx/Db/Adapter/MysqlAdapter.php +++ b/src/Phinx/Db/Adapter/MysqlAdapter.php @@ -1363,7 +1363,7 @@ protected function getColumnSqlDefinition(Column $column): string $def .= $column->getCollation() ? ' COLLATE ' . $column->getCollation() : ''; $def .= !$column->isSigned() && isset($this->signedColumnTypes[$column->getType()]) ? ' unsigned' : ''; - if (!($column->getType() instanceof Literal) || strpos($this->getConnection()->getAttribute(PDO::ATTR_SERVER_VERSION), "MariaDB") === false) { + if (!($column->getType() instanceof Literal) || strpos($this->getConnection()->getAttribute(PDO::ATTR_SERVER_VERSION), 'MariaDB') === false) { $def .= $column->isNull() ? ' NULL' : ' NOT NULL'; }