diff --git a/.github/workflows/pr-drupal-tests.yml b/.github/workflows/pr-drupal-tests.yml index 6637581..6aa84e9 100644 --- a/.github/workflows/pr-drupal-tests.yml +++ b/.github/workflows/pr-drupal-tests.yml @@ -16,6 +16,8 @@ jobs: - examples/drupal-defaults - examples/drupal-export - examples/drupal-import + - examples/drupal-mariadb + - examples/drupal-mariadb-mysql - examples/drupal-mysql8 - examples/drupal-nginx - examples/drupal6 diff --git a/CHANGELOG.md b/CHANGELOG.md index af22155..8763454 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Use mysql command for MariaDB 10.3.x and below + ## v1.5.0 - [May 8, 2024](https://github.com/lando/drupal/releases/tag/v1.5.0) * Updated mariadb plugin and added tooling support for the mariadb executable. [#51](https://github.com/lando/mariadb/issues/51 diff --git a/builders/_drupaly.js b/builders/_drupaly.js index 9c8d093..1d82ee0 100644 --- a/builders/_drupaly.js +++ b/builders/_drupaly.js @@ -163,15 +163,19 @@ const getServices = options => ({ */ const getDbTooling = database => { // Make sure we strip out any version number - database = database.split(':')[0]; + const db = database.split(':')[0]; + const ver = database.split(':')[1]; // Choose wisely - if (database === 'mysql') { + if (db === 'mysql') { return {mysql: mysqlCli}; - } else if (database === 'mariadb') { + } else if (db === 'mariadb' && ver < 10.4) { + // Use mysql command for MariaDB 10.3.x and below + return {mysql: mysqlCli}; + } else if (db === 'mariadb') { return {mariadb: mariadbCli}; - } else if (database === 'postgres') { + } else if (db === 'postgres') { return {psql: postgresCli}; - } else if (database === 'mongo') { + } else if (db === 'mongo') { return {mongo: { service: 'database', description: 'Drop into the mongo shell', diff --git a/examples/drupal-mariadb-mysql/.lando.yml b/examples/drupal-mariadb-mysql/.lando.yml new file mode 100644 index 0000000..e583fb3 --- /dev/null +++ b/examples/drupal-mariadb-mysql/.lando.yml @@ -0,0 +1,9 @@ +name: lando-drupal-mariadb-mysql +recipe: drupal10 +config: + php: '8.3' + composer_version: 2.7.4 + webroot: web + database: 'mariadb:10.3' +plugins: + '@lando/drupal': ../.. diff --git a/examples/drupal-mariadb-mysql/README.md b/examples/drupal-mariadb-mysql/README.md new file mode 100644 index 0000000..aed2723 --- /dev/null +++ b/examples/drupal-mariadb-mysql/README.md @@ -0,0 +1,63 @@ +Drupal MariaDB/MySQL Example +============================ + +This example exists primarily to test the following documentation: + +* [Drupal Recipe](https://docs.devwithlando.io/tutorials/drupal.html) + +Start up tests +-------------- + +Run the following commands to get up and running with this example. + +```bash +# Should poweroff +lando poweroff + +# Should start up successfully +lando start +``` + +Verification commands +--------------------- + +Run the following commands to validate things are rolling as they should. + +```bash +# Should serve from web folder +lando ssh -s appserver -c "curl -L localhost" | grep "MySQL" + +# Should use 8.3 as the default php version +lando php -v | grep "PHP 8.3" + +# Should use composer 2.7.4 +lando composer -V | grep 2.7.4 + +# Should be running apache 2.4 by default +lando ssh -s appserver -c "apachectl -V" | grep 2.4 +lando ssh -s appserver -c "curl -IL localhost" | grep Server | grep 2.4 + +# Should be running mariadb 10.3.x +lando mysql -V | grep "MariaDB" | grep 10.3. + +# Should not enable xdebug by default +lando php -m | grep xdebug || echo $? | grep 1 + +# Should use the default database connection info +lando mysql -udrupal10 -pdrupal10 drupal10 -e quit + +# Should use the default mariadb config file +lando ssh -s database -c "cat /opt/bitnami/mariadb/conf/my_custom.cnf" | grep "innodb_lock_wait_timeout = 121" +lando mysql -e "show variables;" | grep innodb_lock_wait_timeout | grep 121 +``` + +Destroy tests +------------- + +Run the following commands to trash this app like nothing ever happened. + +```bash +# Should be destroyed with success +lando destroy -y +lando poweroff +``` diff --git a/examples/drupal-mariadb-mysql/web/index.php b/examples/drupal-mariadb-mysql/web/index.php new file mode 100644 index 0000000..4546ff9 --- /dev/null +++ b/examples/drupal-mariadb-mysql/web/index.php @@ -0,0 +1 @@ +MySQL diff --git a/examples/drupal-mariadb-mysql/web/info.php b/examples/drupal-mariadb-mysql/web/info.php new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/examples/drupal-mariadb-mysql/web/info.php @@ -0,0 +1 @@ + diff --git a/lib/utils.js b/lib/utils.js index 710ba6c..b017626 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -73,15 +73,19 @@ const getDrushUrl = version => `https://github.com/drush-ops/drush/releases/down */ exports.getDbTooling = database => { // Make sure we strip out any version number - database = database.split(':')[0]; + db = database.split(':')[0]; + ver = database.split(':')[1]; // Choose wisely - if (database === 'mysql') { + if (db === 'mysql') { return {mysql: mysqlCli}; - } else if (database === 'mariadb') { + } else if (db === 'mariadb' && ver < 10.4) { + // Use mysql command for MariaDB 10.3.x and below + return {mysql: mysqlCli}; + } else if (db === 'mariadb') { return {mariadb: mariadbCli}; - } else if (database === 'postgres') { + } else if (db === 'postgres') { return {psql: postgresCli}; - } else if (database === 'mongo') { + } else if (db === 'mongo') { return {mongo: { service: 'database', description: 'Drop into the mongo shell',