Skip to content

Commit

Permalink
Use mysql command for MariaDB 10.3.x and below
Browse files Browse the repository at this point in the history
  • Loading branch information
uberhacker committed May 25, 2024
1 parent 625eae0 commit 7774105
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pr-drupal-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 9 additions & 5 deletions builders/_drupaly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 9 additions & 0 deletions examples/drupal-mariadb-mysql/.lando.yml
Original file line number Diff line number Diff line change
@@ -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': ../..
63 changes: 63 additions & 0 deletions examples/drupal-mariadb-mysql/README.md
Original file line number Diff line number Diff line change
@@ -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
```
1 change: 1 addition & 0 deletions examples/drupal-mariadb-mysql/web/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MySQL
1 change: 1 addition & 0 deletions examples/drupal-mariadb-mysql/web/info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php phpinfo(); ?>
14 changes: 9 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 7774105

Please sign in to comment.