Skip to content

Commit

Permalink
feat: change database default to mariadb:10.11, fixes #5797 (#5836)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Feb 23, 2024
1 parent e5e0238 commit 20a58d4
Show file tree
Hide file tree
Showing 37 changed files with 72 additions and 150 deletions.
3 changes: 2 additions & 1 deletion .buildkite/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ fi
# sleep 10
#fi

docker volume rm ddev-global-cache >/dev/null 2>&1 || true
# We don't want any docker volumes to be existing and changing behavior
docker volume prune -a -f >/dev/null 2>&1 || true

# Run any testbot maintenance that may need to be done
echo "--- running testbot_maintenance.sh"
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/push-tagged-dbimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:
inputs:
tag:
description: Base tag for pushed dbimage (v1.19.4 for example)'
description: Base tag for pushed dbimage (v1.22.7 for example)'
required: true
default: ""
debug_enabled:
Expand Down Expand Up @@ -37,11 +37,8 @@ jobs:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:master
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@master
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
Expand Down
26 changes: 11 additions & 15 deletions cmd/ddev/cmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,19 @@ func TestConfigDatabaseVersion(t *testing.T) {
origDir, _ := os.Getwd()
versionsToTest := nodeps.GetValidDatabaseVersions()
if os.Getenv("GOTEST_SHORT") != "" {
versionsToTest = []string{"mariadb:10.3", "mysql:5.7"}
versionsToTest = []string{"mariadb:10.11", "mysql:8.0", "postgres:16"}
}

// Create a temporary directory and switch to it.
tmpDir := testcommon.CreateTmpDir(t.Name())
err := os.Chdir(tmpDir)
testDir := testcommon.CreateTmpDir(t.Name())
err := os.Chdir(testDir)
require.NoError(t, err)

err = globalconfig.RemoveProjectInfo(t.Name())
assert.NoError(err)

out, err := exec.RunHostCommand(DdevBin, "config", "--project-name", t.Name())
assert.NoError(err, "Failed running ddev config --auto: %s", out)
assert.NoError(err, "Failed running ddev config --project-name: %s", out)

err = globalconfig.ReadGlobalConfig()
require.NoError(t, err)
Expand All @@ -501,40 +501,36 @@ func TestConfigDatabaseVersion(t *testing.T) {
assert.NoError(err)
err = os.Chdir(origDir)
assert.NoError(err)
_ = os.RemoveAll(tmpDir)
_ = os.RemoveAll(testDir)
})

_, err = app.ReadConfig(false)
assert.NoError(err)
assert.Equal(nodeps.MariaDB, app.Database.Type)
assert.Equal(nodeps.MariaDBDefaultVersion, app.Database.Version)

err = app.Start()
assert.NoError(err)
err = app.Stop(true, false)
assert.NoError(err)

// Verify behavior with no existing config.yaml. It should
// add a database into the config and nothing else
for _, dbTypeVersion := range versionsToTest {
_ = app.Stop(true, false)
parts := strings.Split(dbTypeVersion, ":")
err = os.RemoveAll(filepath.Join(tmpDir, ".ddev"))
err = os.RemoveAll(filepath.Join(testDir, ".ddev"))
assert.NoError(err)
out, err := exec.RunHostCommand(DdevBin, "config", "--database", dbTypeVersion)
assert.NoError(err, "Failed to run ddev config --database %s: %s", dbTypeVersion, out)
out, err := exec.RunHostCommand(DdevBin, "config", "--database="+dbTypeVersion, "--project-name="+t.Name())
require.NoError(t, err, "Failed to run ddev config --database %s: %s", dbTypeVersion, out)
assert.Contains(out, "You may now run 'ddev start'")

// First test the bare explicit values found in the config.yaml,
// without the NewApp adjustments
app := &ddevapp.DdevApp{}
assert.NoError(err)
err = app.LoadConfigYamlFile(filepath.Join(tmpDir, ".ddev", "config.yaml"))
err = app.LoadConfigYamlFile(filepath.Join(testDir, ".ddev", "config.yaml"))
assert.NoError(err)
assert.Equal(parts[0], app.Database.Type)
assert.Equal(parts[1], app.Database.Version)

// Now use NewApp() to load, so that we get the full logic of that function.
app, err = ddevapp.NewApp(tmpDir, false)
app, err = ddevapp.NewApp(testDir, false)
assert.NoError(err)
t.Cleanup(func() {
err = app.Stop(true, false)
Expand Down
3 changes: 2 additions & 1 deletion cmd/ddev/cmd/debug-migrate-database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func TestDebugMigrateDatabase(t *testing.T) {
Cmd: `mysql -N -e 'SELECT VERSION();'`,
})
require.NoError(t, err)
require.True(t, strings.HasPrefix(out, nodeps.MariaDB104))
// It should have our default version
require.True(t, strings.HasPrefix(out, nodeps.MariaDBDefaultVersion))

// Import a database so we have something to work with
err = app.ImportDB(filepath.Join(origDir, "testdata", t.Name(), "users.sql"), "", false, false, "")
Expand Down
3 changes: 2 additions & 1 deletion cmd/ddev/cmd/export-db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ func TestCmdExportDB(t *testing.T) {
assert.NoError(err, "export-db failure output=%s", string(byteout))
assert.Contains(string(byteout), fmt.Sprintf("Wrote database dump from project '%s' database '%s' to file %s in plain text format", site.Name, "nondefault", outputFile))
assert.FileExists(outputFile)
assert.True(fileutil.FgrepStringInFile(outputFile, "INSERT INTO `nondefault_table` VALUES (0,'13751eca-19cf-41c2-90d4-9363f3a07c45','en'),"))
assert.True(fileutil.FgrepStringInFile(outputFile, "INSERT INTO `nondefault_table` VALUES"))
assert.True(fileutil.FgrepStringInFile(outputFile, "(0,'13751eca-19cf-41c2-90d4-9363f3a07c45','en'),"))

_, _, err = app.Exec(&ddevapp.ExecOpts{
Service: "db",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion containers/ddev-dbserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN for item in "75DD C3C4 A499 F1A1 8CB5 F3C8 CBF8 D6FD 518E 17E1" "126C 0D24
# and remove it here
RUN rm -f /etc/apt/sources.list.d/mariadb.list /etc/apt/sources.list.d/percona.list

RUN apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get -qq install -y -o Dpkg::Options::="--force-confold" curl gnupg2 less lsb-release pv tzdata vim wget >/dev/null
RUN apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" bzip2 curl gnupg2 less lsb-release pv tzdata vim wget

# If on 14.04 Ubuntu the percona repositories won't allow TLS apparently, so
# Use http when connecting. This currently only affects MariaDB 5.5
Expand Down
2 changes: 1 addition & 1 deletion docs/content/users/extend/database-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DDEV supports many versions of the MariaDB, MySQL, and PostgreSQL database servers.

The default database type is MariaDB, and the default version is currently 10.4, but you can use MariaDB versions 5.5-10.8 and 10.11, MySQL 5.5-8.0, and Postgres 9-16. (New LTS versions of each of these are typically added soon after release. The very old versions are kept for compatibility with older projects.)
The default database type is MariaDB, and the default version is currently 10.11, but you can use MariaDB versions 5.5-10.8 and 10.11, MySQL 5.5-8.0, and Postgres 9-16. (New LTS versions of each of these are typically added soon after release. The very old versions are kept for compatibility with older projects.)

You could set these using the [`ddev config`](../usage/commands.md#config) command like this:

Expand Down
2 changes: 1 addition & 1 deletion docs/content/users/usage/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Flags:
* `--composer-root`: Overrides the default Composer root directory for the web service.
* `--composer-root-default`: Unsets a web service Composer root directory override.
* `--composer-version`: Specify override for Composer version in the web container. This may be `""`, `"1"`, `"2"`, `"2.2"`, `"stable"`, `"preview"`, `"snapshot"`, or a specific version.
* `--database`: Specify the database type:version to use. Defaults to `mariadb:10.4`.
* `--database`: Specify the database type:version to use. Defaults to `mariadb:10.11`.
* `--db-image`: Sets the db container image.
* `--db-image-default`: Sets the default db container image for this DDEV version.
* `--db-working-dir`: Overrides the default working directory for the db service.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddevapp/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
)

// GetExistingDBType returns type/version like mariadb:10.4 or postgres:13 or "" if no existing volume
// GetExistingDBType returns type/version like mariadb:10.11 or postgres:13 or "" if no existing volume
// This has to make a Docker container run so is fairly costly.
func (app *DdevApp) GetExistingDBType() (string, error) {
_, out, err := dockerutil.RunSimpleContainer(versionconstants.BusyboxImage, "GetExistingDBType-"+app.Name+"-"+util.RandString(6), []string{"sh", "-c", "( test -f /var/tmp/mysql/db_mariadb_version.txt && cat /var/tmp/mysql/db_mariadb_version.txt ) || ( test -f /var/tmp/postgres/PG_VERSION && cat /var/tmp/postgres/PG_VERSION) || true"}, []string{}, []string{}, []string{app.GetMariaDBVolumeName() + ":/var/tmp/mysql", app.GetPostgresVolumeName() + ":/var/tmp/postgres"}, "", true, false, map[string]string{`com.ddev.site-name`: app.GetName()}, nil)
Expand Down
50 changes: 27 additions & 23 deletions pkg/ddevapp/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,33 @@ func TestDBTypeVersionFromString(t *testing.T) {
assert := asrt.New(t)

expectations := map[string]string{
"9": "postgres:9",
"9.6": "postgres:9",
"10": "postgres:10",
"11": "postgres:11",
"12": "postgres:12",
"13": "postgres:13",
"14": "postgres:14",
"5.5": "mariadb:5.5",
"5.6": "mysql:5.6",
"5.7": "mysql:5.7",
"8.0": "mysql:8.0",
"10.0": "mariadb:10.0",
"10.1": "mariadb:10.1",
"10.2": "mariadb:10.2",
"10.3": "mariadb:10.3",
"10.4": "mariadb:10.4",
"10.5": "mariadb:10.5",
"10.6": "mariadb:10.6",
"10.7": "mariadb:10.7",
"mariadb_10.2": "mariadb:10.2",
"mariadb_10.3": "mariadb:10.3",
"mysql_5.7": "mysql:5.7",
"mysql_8.0": "mysql:8.0",
"9": "postgres:9",
"9.6": "postgres:9",
"10": "postgres:10",
"11": "postgres:11",
"12": "postgres:12",
"13": "postgres:13",
"14": "postgres:14",
"5.5": "mariadb:5.5",
"5.6": "mysql:5.6",
"5.7": "mysql:5.7",
"8.0": "mysql:8.0",
"10.0": "mariadb:10.0",
"10.1": "mariadb:10.1",
"10.2": "mariadb:10.2",
"10.3": "mariadb:10.3",
"10.4": "mariadb:10.4",
"10.5": "mariadb:10.5",
"10.6": "mariadb:10.6",
"10.7": "mariadb:10.7",

"mariadb_10.2": "mariadb:10.2",
"mariadb_10.3": "mariadb:10.3",
"mariadb_10.4": "mariadb:10.4",
"mariadb_10.7": "mariadb:10.7",
"mariadb_10.11": "mariadb:10.11",
"mysql_5.7": "mysql:5.7",
"mysql_8.0": "mysql:8.0",
}

for input, expectation := range expectations {
Expand Down
14 changes: 10 additions & 4 deletions pkg/ddevapp/ddevapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ func TestDdevImportDB(t *testing.T) {
assert.NoError(err)
assert.Equal("users\n", out, "Failed to find users table for file %s, stdout='%s', stderr='%s'", file, out, stderr)

c[nodeps.MariaDB] = `set -eu -o pipefail; mysql -N -e 'SHOW DATABASES;' | egrep -v "^(information_schema|performance_schema|mysql)$"`
c[nodeps.MariaDB] = `set -eu -o pipefail; mysql -N -e 'SHOW DATABASES;' | egrep -v "^(information_schema|performance_schema|mysql|sys)$"`
c[nodeps.Postgres] = `set -eu -o pipefail; psql -t -c "SELECT datname FROM pg_database;" | egrep -v "template?|postgres"`

// Verify that no extra database was created
Expand Down Expand Up @@ -1608,7 +1608,7 @@ func checkImportDbImports(t *testing.T, app *ddevapp.DdevApp) {
// Verify that no additional database was created (this one has a CREATE DATABASE statement)
out, _, err = app.Exec(&ddevapp.ExecOpts{
Service: "db",
Cmd: `mysql -N -e 'SHOW DATABASES;' | egrep -v "^(information_schema|performance_schema|mysql)$"`,
Cmd: `mysql -N -e 'SHOW DATABASES;' | egrep -v "^(information_schema|performance_schema|mysql|sys)$"`,
})
assert.NoError(err)
assert.Equal("db\n", out)
Expand All @@ -1623,7 +1623,7 @@ func TestDdevAllDatabases(t *testing.T) {
dbVersions = nodeps.RemoveItemFromSlice(dbVersions, "postgres:9")
//Use a smaller list if GOTEST_SHORT
if os.Getenv("GOTEST_SHORT") != "" {
dbVersions = []string{"postgres:10", "postgres:14", "mariadb:10.3", "mariadb:10.4", "mariadb:10.11", "mysql:8.0", "mysql:5.7"}
dbVersions = []string{"postgres:14", "mariadb:10.4", "mariadb:10.11", "mysql:8.0", "mysql:5.7"}
t.Logf("Using limited set of database servers because GOTEST_SHORT is set (%v)", dbVersions)
}

Expand Down Expand Up @@ -1678,7 +1678,13 @@ func TestDdevAllDatabases(t *testing.T) {

startErr := app.Start()
if startErr != nil {
assert.NoError(startErr, "failed to start %s:%s", dbType, dbVersion)
stdout, stderr, err := app.Exec(&ddevapp.ExecOpts{
Service: "db",
Cmd: `ls -lR /var/lib/mysql`,
})
t.Logf("status of /var/lib/mysql; err=%v, stdout=%s\nstderr=%s", err, stdout, stderr)
logs, _ := app.CaptureLogs("db", false, "50")
assert.NoError(startErr, "failed to start %s:%s, dblogs=\n=========\n%s\n=========\n", dbType, dbVersion, logs)
err = app.Stop(true, false)
assert.NoError(err)
t.Errorf("Continuing/skippping %s due to app.Start() failure %v", dbVersion, startErr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddevapp/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ConfigInstructions = `
# database:
# type: <dbtype> # mysql, mariadb, postgres
# version: <version> # database version, like "10.4" or "8.0"
# version: <version> # database version, like "10.11" or "8.0"
# MariaDB versions can be 5.5-10.8 and 10.11, MySQL versions can be 5.5-8.0
# PostgreSQL versions can be 9-16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

database:
type: mariadb
version: 10.4
version: 10.11
php_version: 8.0
performance_mode: "none"
webserver_type: apache-fpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
database:
type: "mariadb"
version: "10.11"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
database:
type: "mariadb"
version: "10.8"

0 comments on commit 20a58d4

Please sign in to comment.