diff --git a/CHANGELOG.md b/CHANGELOG.md index 877da0853..85a3f0fc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +### Bug Fixes + +* Fixed issue with importing databases to a service with the "default" `database` named database. [lando/mysql#53](https://github.com/lando/mysql/issues/53) + ## v3.21.0 - [May 25, 2024](https://github.com/lando/core/releases/tag/v3.21.0) ### Bug Fixes diff --git a/builders/lando-v4.js b/builders/lando-v4.js index a0ee70a8c..74bc2a233 100644 --- a/builders/lando-v4.js +++ b/builders/lando-v4.js @@ -78,7 +78,7 @@ module.exports = { // add some upstream stuff and legacy stuff upstream.appMount = config['app-mount'].destination; - upstream.legacy = merge({}, {meUser: username}, upstream.legacy ?? {}); + upstream.legacy = merge({}, upstream.legacy ?? {}, {meUser: username}); // this will change but for right now i just need the image stuff to passthrough upstream.config = {image: config.image}; diff --git a/examples/sql-helpers/.lando.sqlhelpers.yml b/examples/sql-helpers/.lando.sqlhelpers.yml index 42acb1eac..6e9adb8f1 100644 --- a/examples/sql-helpers/.lando.sqlhelpers.yml +++ b/examples/sql-helpers/.lando.sqlhelpers.yml @@ -13,6 +13,19 @@ services: MYSQL_DATABASE: lando_test MARIADB_USER: test MARIADB_PASSWORD: test + mariadb-default: + api: 3 + type: lando + healthcheck: mysqladmin ping -h mariadb-default -u test -ptest + services: + image: bitnami/mariadb:10.4 + command: /opt/bitnami/scripts/mariadb/entrypoint.sh /opt/bitnami/scripts/mariadb/run.sh + environment: + ALLOW_EMPTY_PASSWORD: yes + MARIADB_DATABASE: database + MYSQL_DATABASE: database + MARIADB_USER: test + MARIADB_PASSWORD: test mysql57: api: 3 @@ -27,6 +40,19 @@ services: MYSQL_DATABASE: lando_test MYSQL_PASSWORD: test MYSQL_USER: test + mysql57-default: + api: 3 + type: lando + healthcheck: mysqladmin ping -h mysql57-default -u test -ptest + services: + image: bitnami/mysql:5.7 + command: /opt/bitnami/scripts/mysql/entrypoint.sh /opt/bitnami/scripts/mysql/run.sh + environment: + ALLOW_EMPTY_PASSWORD: yes + MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password + MYSQL_DATABASE: database + MYSQL_PASSWORD: test + MYSQL_USER: test mysql80: api: 3 @@ -41,6 +67,19 @@ services: MYSQL_DATABASE: lando_test MYSQL_PASSWORD: test MYSQL_USER: test + mysql80-default: + api: 3 + type: lando + healthcheck: mysqladmin ping -h mysql80-default -u test -ptest + services: + image: bitnami/mysql:8.0 + command: /opt/bitnami/scripts/mysql/entrypoint.sh /opt/bitnami/scripts/mysql/run.sh + environment: + ALLOW_EMPTY_PASSWORD: yes + MYSQL_AUTHENTICATION_PLUGIN: caching_sha2_password + MYSQL_DATABASE: database + MYSQL_PASSWORD: test + MYSQL_USER: test postgres16: api: 3 @@ -53,6 +92,17 @@ services: ALLOW_EMPTY_PASSWORD: yes POSTGRESQL_DATABASE: lando_test POSTGRES_DB: lando_test + postgres16-default: + api: 3 + type: lando + healthcheck: pg_isready -h postgres16-default -U postgres + services: + image: bitnami/postgresql:16 + command: /opt/bitnami/scripts/postgresql/entrypoint.sh /opt/bitnami/scripts/postgresql/run.sh + environment: + ALLOW_EMPTY_PASSWORD: yes + POSTGRESQL_DATABASE: database + POSTGRES_DB: database plugins: "@lando/core": "../../.." diff --git a/examples/sql-helpers/README.md b/examples/sql-helpers/README.md index 8be680250..ea004c0a7 100644 --- a/examples/sql-helpers/README.md +++ b/examples/sql-helpers/README.md @@ -26,21 +26,41 @@ cd sqlhelpers lando ssh -s mariadb -c "/helpers/sql-import.sh testdata1.sql" lando ssh -s mariadb -c "mysql -utest -ptest lando_test -e 'select * from lando_test'" | grep "lando_original" +# Should import test data into mariadb-default +cd sqlhelpers +lando ssh -s mariadb-default -c "/helpers/sql-import.sh testdata1.sql" +lando ssh -s mariadb-default -c "mysql -utest -ptest database -e 'select * from lando_test'" | grep "lando_original" + # Should import test data into mysql57 cd sqlhelpers lando ssh -s mysql57 -c "/helpers/sql-import.sh testdata1.sql" lando ssh -s mysql57 -c "mysql -utest -ptest lando_test -e 'select * from lando_test'" | grep "lando_original" +# Should import test data into mysql57-default +cd sqlhelpers +lando ssh -s mysql57-default -c "/helpers/sql-import.sh testdata1.sql" +lando ssh -s mysql57-default -c "mysql -utest -ptest database -e 'select * from lando_test'" | grep "lando_original" + # Should import test data into mysql80 cd sqlhelpers lando ssh -s mysql80 -c "/helpers/sql-import.sh testdata1.sql" lando ssh -s mysql80 -c "mysql -utest -ptest lando_test -e 'select * from lando_test'" | grep "lando_original" +# Should import test data into mysql80-default +cd sqlhelpers +lando ssh -s mysql80-default -c "/helpers/sql-import.sh testdata1.sql" +lando ssh -s mysql80-default -c "mysql -utest -ptest database -e 'select * from lando_test'" | grep "lando_original" + # Should import test data into postgres16 cd sqlhelpers lando ssh -s postgres16 -c "/helpers/sql-import.sh testdata1.sql" lando ssh -s postgres16 -c "psql -U postgres -d lando_test -c 'select * from lando_test'" | grep "lando_original" +# Should import test data into postgres16-default +cd sqlhelpers +lando ssh -s postgres16-default -c "/helpers/sql-import.sh testdata1.sql" +lando ssh -s postgres16-default -c "psql -U postgres -d database -c 'select * from lando_test'" | grep "lando_original" + # Should export gzipped files from mariadb cd sqlhelpers lando ssh -s mariadb -c "/helpers/sql-export.sh mariadb_dump.sql" -u root diff --git a/package-lock.json b/package-lock.json index 670185bb2..a42088612 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@lando/core", - "version": "3.21.0-beta.14", + "version": "3.21.0", "license": "GPL-3.0", "dependencies": { "@npmcli/arborist": "^6.2.9", diff --git a/scripts/sql-import.sh b/scripts/sql-import.sh index 6db2c2b7f..2266cb8a5 100755 --- a/scripts/sql-import.sh +++ b/scripts/sql-import.sh @@ -108,8 +108,8 @@ if [ "$WIPE" == "true" ]; then SQLSTART="mysql -h $HOST -P $PORT -u $USER ${LANDO_EXTRA_DB_IMPORT_ARGS}" # Drop and recreate database - $SQLSTART -e "DROP DATABASE IF EXISTS ${DATABASE}" - $SQLSTART -e "CREATE DATABASE ${DATABASE}" + $SQLSTART -e "DROP DATABASE IF EXISTS \`${DATABASE}\`" + $SQLSTART -e "CREATE DATABASE \`${DATABASE}\`" fi fi