diff --git a/containers/ddev-dbserver/10.1/files/migrate_file_to_volume.sh b/containers/ddev-dbserver/10.1/files/migrate_file_to_volume.sh deleted file mode 100755 index cfd701e0575..00000000000 --- a/containers/ddev-dbserver/10.1/files/migrate_file_to_volume.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -set -x -set -eu -set -o pipefail - -# This script is used to migrate a ddev bind-mounted database to a docker-volume mounted database -# It is actually just for the initial migration of v1.0.0-era databases to (hopefully) v1.1.0 -# docker-volume-mounted databases, around 2018-08-02. It should end up being not useful within a few -# months. -# -# Run this command in the project directory: -# docker run -t -u "$(id -u):$(id -g)" -e SNAPSHOT_NAME=/mysql:/mysqlmount" --rm --entrypoint=/migrate_file_to_volume.sh drud/ddev-dbserver: - -if [ -z "${SNAPSHOT_NAME:-}" ] ; then - echo "SNAPSHOT_NAME environment variable must be set" - exit 101 -fi - -OUTDIR="/mnt/ddev_config/db_snapshots/${SNAPSHOT_NAME}" -SOCKET=/var/tmp/mysql.sock - -mkdir -p $OUTDIR - -if [ ! -d "/mysqlmount/mysql" ]; then - echo "No mysql bind-mount directory was found, aborting" - exit 102 -fi - -sudo mkdir -p /var/lib/mysql && sudo chmod -R ugo+w /var/lib/mysql -cp -r /mysqlmount/* /var/lib/mysql - - -# Wait for mysql server to be ready. -function serverwait { - for i in {60..0}; - do - if mysqladmin ping -uroot --socket=$SOCKET >/dev/null 2>&1; then - return 0 - fi - # Test to make sure we got it started in the first place. kill -s 0 just tests to see if process exists. - if ! kill -s 0 $pid 2>/dev/null; then - echo "MariaDB initialization startup failed" - return 2 - fi - echo "MariaDB initialization startup process in progress... Try# $i" - sleep 1 - done - return 1 -} - -# Using --skip-grant-tables here becasue some old projects may not have working -# --user root --password root -mysqld --skip-networking --skip-grant-tables --socket=$SOCKET 2>&1 & -pid=$! -if ! serverwait ; then - echo "Failed to get mysqld running" - exit 103 -fi - -mariabackup --backup --target-dir=$OUTDIR --user root --socket=$SOCKET 2>&1 -if [ "$?" != 0 ] ; then - echo "Failed mariabackup command."; - exit $((200+$?)); -fi - -# Wait for mysqld to exit -kill -s TERM "$pid" && wait "$pid" - -echo "migration in: $OUTDIR" diff --git a/containers/ddev-dbserver/10.2/files/migrate_file_to_volume.sh b/containers/ddev-dbserver/10.2/files/migrate_file_to_volume.sh deleted file mode 100755 index cfd701e0575..00000000000 --- a/containers/ddev-dbserver/10.2/files/migrate_file_to_volume.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -set -x -set -eu -set -o pipefail - -# This script is used to migrate a ddev bind-mounted database to a docker-volume mounted database -# It is actually just for the initial migration of v1.0.0-era databases to (hopefully) v1.1.0 -# docker-volume-mounted databases, around 2018-08-02. It should end up being not useful within a few -# months. -# -# Run this command in the project directory: -# docker run -t -u "$(id -u):$(id -g)" -e SNAPSHOT_NAME=/mysql:/mysqlmount" --rm --entrypoint=/migrate_file_to_volume.sh drud/ddev-dbserver: - -if [ -z "${SNAPSHOT_NAME:-}" ] ; then - echo "SNAPSHOT_NAME environment variable must be set" - exit 101 -fi - -OUTDIR="/mnt/ddev_config/db_snapshots/${SNAPSHOT_NAME}" -SOCKET=/var/tmp/mysql.sock - -mkdir -p $OUTDIR - -if [ ! -d "/mysqlmount/mysql" ]; then - echo "No mysql bind-mount directory was found, aborting" - exit 102 -fi - -sudo mkdir -p /var/lib/mysql && sudo chmod -R ugo+w /var/lib/mysql -cp -r /mysqlmount/* /var/lib/mysql - - -# Wait for mysql server to be ready. -function serverwait { - for i in {60..0}; - do - if mysqladmin ping -uroot --socket=$SOCKET >/dev/null 2>&1; then - return 0 - fi - # Test to make sure we got it started in the first place. kill -s 0 just tests to see if process exists. - if ! kill -s 0 $pid 2>/dev/null; then - echo "MariaDB initialization startup failed" - return 2 - fi - echo "MariaDB initialization startup process in progress... Try# $i" - sleep 1 - done - return 1 -} - -# Using --skip-grant-tables here becasue some old projects may not have working -# --user root --password root -mysqld --skip-networking --skip-grant-tables --socket=$SOCKET 2>&1 & -pid=$! -if ! serverwait ; then - echo "Failed to get mysqld running" - exit 103 -fi - -mariabackup --backup --target-dir=$OUTDIR --user root --socket=$SOCKET 2>&1 -if [ "$?" != 0 ] ; then - echo "Failed mariabackup command."; - exit $((200+$?)); -fi - -# Wait for mysqld to exit -kill -s TERM "$pid" && wait "$pid" - -echo "migration in: $OUTDIR" diff --git a/pkg/ddevapp/ddevapp.go b/pkg/ddevapp/ddevapp.go index 866695feabb..d35353664cb 100644 --- a/pkg/ddevapp/ddevapp.go +++ b/pkg/ddevapp/ddevapp.go @@ -8,8 +8,6 @@ import ( "path/filepath" "strconv" - "github.com/drud/ddev/pkg/globalconfig" - "golang.org/x/crypto/ssh/terminal" "strings" @@ -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 @@ -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. diff --git a/pkg/ddevapp/ddevapp_test.go b/pkg/ddevapp/ddevapp_test.go index 20fd6e52c29..8880fbcb316 100644 --- a/pkg/ddevapp/ddevapp_test.go +++ b/pkg/ddevapp/ddevapp_test.go @@ -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) diff --git a/pkg/ddevapp/testdata/db_migration/d7_to_migrate.tgz b/pkg/ddevapp/testdata/db_migration/d7_to_migrate.tgz deleted file mode 100644 index 39824ec9a43..00000000000 Binary files a/pkg/ddevapp/testdata/db_migration/d7_to_migrate.tgz and /dev/null differ diff --git a/pkg/version/version.go b/pkg/version/version.go index d3f9ef39368..c7308634061 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -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"