Skip to content

Commit

Permalink
The old bind-mounted db code is now fully obsolete, remove it (#1506)
Browse files Browse the repository at this point in the history
* Remove old bind-mount db port capabilities and tests

* Bump ddev-dbserver version
  • Loading branch information
rfay committed Mar 25, 2019
1 parent c39d6bd commit 2ccc3f4
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 225 deletions.
70 changes: 0 additions & 70 deletions containers/ddev-dbserver/10.1/files/migrate_file_to_volume.sh

This file was deleted.

70 changes: 0 additions & 70 deletions containers/ddev-dbserver/10.2/files/migrate_file_to_volume.sh

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/ddevapp/ddevapp.go
Expand Up @@ -8,8 +8,6 @@ import (
"path/filepath"
"strconv"

"github.com/drud/ddev/pkg/globalconfig"

"golang.org/x/crypto/ssh/terminal"

"strings"
Expand Down Expand Up @@ -667,16 +665,6 @@ func (app *DdevApp) Start() error {
util.Warning("Your %s version is %s, but ddev is version %s. \nPlease run 'ddev config' to update your config.yaml. \nddev may not operate correctly until you do.", app.ConfigPath, app.APIVersion, version.DdevVersion)
}

// IF we need to do a DB migration to docker-volume, do it here.
// It actually does the app.Start() at the end of the migration, so we can return successfully here.
migrationDone, err := app.migrateDbIfRequired()
if err != nil {
return fmt.Errorf("Failed to migrate db from bind-mounted db: %v", err)
}
if migrationDone {
return nil
}

err = app.ProcessHooks("pre-start")
if err != nil {
return err
Expand Down Expand Up @@ -1472,19 +1460,6 @@ func (app *DdevApp) GetProvider() (Provider, error) {
return app.providerInstance, err
}

// migrateDbIfRequired checks for need of db migration to docker-volume-mount and if needed, does the migration.
// This should be important around the time of its release, 2018-08-02 or so, but should be increasingly
// irrelevant after that and can eventually be removed.
// Returns bool (true if migration was done) and err
func (app *DdevApp) migrateDbIfRequired() (bool, error) {
dataDir := filepath.Join(globalconfig.GetGlobalDdevDir(), app.Name, "mysql")

if fileutil.FileExists(dataDir) {
return false, fmt.Errorf("sorry, it is not possible to migrate bind-mounted databases using ddev v1.3+, please use ddev v1.2 to migrate, or just 'mv ~/.ddev/%s/mysql ~/.ddev/%s/mysql.saved' and then restart and reload with 'ddev import-db'", app.Name, app.Name)
}
return false, nil
}

// getWorkingDir will determine the appropriate working directory for an Exec/ExecWithTty command
// by consulting with the project configuration. If no dir is specified for the service, an
// empty string will be returned.
Expand Down
59 changes: 0 additions & 59 deletions pkg/ddevapp/ddevapp_test.go
Expand Up @@ -2144,65 +2144,6 @@ func TestWebserverType(t *testing.T) {
}
}

// TestDbMigration tests migration from bind-mounted db to volume-mounted db
// This should be important around the time of its release, 2018-08-02 or so, but should be increasingly
// irrelevant after that and can eventually be removed.
func TestDbMigration(t *testing.T) {
assert := asrt.New(t)
runTime := testcommon.TimeTrack(time.Now(), fmt.Sprintf("TestDbMigration"))

app := &ddevapp.DdevApp{}
dbMigrationTarball, err := filepath.Abs(filepath.Join("testdata", "db_migration", "d7_to_migrate.tgz"))
assert.NoError(err)

// Use d7 only for this test
site := FullTestSites[2]

// If running this with GOTEST_SHORT we have to create the directory, tarball etc.
if site.Dir == "" || !fileutil.FileExists(site.Dir) {
err = site.Prepare()
if err != nil {
t.Fatalf("Prepare() failed on TestSite.Prepare() site=%s, err=%v", site.Name, err)
}
}

switchDir := site.Chdir()
testcommon.ClearDockerEnv()

err = app.Init(site.Dir)
assert.NoError(err)

dataDir := filepath.Join(globalconfig.GetGlobalDdevDir(), app.Name, "mysql")

// Remove any existing dataDir or migration backups
if fileutil.FileExists(dataDir) {
err = os.RemoveAll(dataDir)
assert.NoError(err)
}
if fileutil.FileExists(dataDir + "_migrated.bak") {
err = os.RemoveAll(dataDir + "_migrated.bak")
assert.NoError(err)
}

// Untar the to-migrate db into old-style dataDir (~/.ddev/projectname/mysql)
err = os.MkdirAll(dataDir, 0755)
require.NoError(t, err)
err = archive.Untar(dbMigrationTarball, dataDir, "")
require.NoError(t, err)
defer os.RemoveAll(dataDir)

_, err = app.CreateSettingsFile()
assert.NoError(err)

// app.Start() will discover the mysql directory and migrate it to a snapshot.
err = app.Start()
assert.Error(err)
assert.Contains(err.Error(), "it is not possible to migrate bind-mounted")

runTime()
switchDir()
}

// TestInternalAndExternalAccessToURL checks we can access content from host and from inside container by URL (with port)
func TestInternalAndExternalAccessToURL(t *testing.T) {
assert := asrt.New(t)
Expand Down
Binary file removed pkg/ddevapp/testdata/db_migration/d7_to_migrate.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion pkg/version/version.go
Expand Up @@ -49,7 +49,7 @@ var WebTag = "v1.6.0" // Note that this can be overridden by make
var DBImg = "drud/ddev-dbserver"

// BaseDBTag is the main tag, DBTag is constructed from it
var BaseDBTag = "20190227_mariadb_on_debian"
var BaseDBTag = "20190322_remove_bind_db_code"

// DBAImg defines the default phpmyadmin image tag used for applications.
var DBAImg = "drud/phpmyadmin"
Expand Down

0 comments on commit 2ccc3f4

Please sign in to comment.