ddev / ddev

Docker-based local PHP+Node.js web development environments
https://ddev.com
Apache License 2.0
2.43k stars 579 forks source link

Can't create snapshot with same name if there's existing one with different database engine #6045

Open hkirsman opened 1 month ago

hkirsman commented 1 month ago

Is there an existing issue for this?

Output of ddev debug test

Expand `ddev debug test` diagnostic information ``` I don't think for the current issue this is not needed but I'll send it if you really need it. ```

Expected Behavior

I have snapshot main-mariadb_10.4.gz . When I delete my local env, switch from mariadb to mysql in config.yaml and try to create snapshot, it should be able to do so because there's no main-mysql_10.4.gz snapshot yet.

Actual Behavior

I'm greeting with incorrect error: Failed to snapshot example.com: snapshot main-mysql_8.0.gz already exists, please use another snapshot name or clean up snapshots with ddev snapshot --cleanup

That file does not exist. So I guess it only checks for the snapshot name itself, then generates the error based on current setup.

Steps To Reproduce

  1. Start with mariadb configuration
name: example.com
type: drupal10
docroot: web
php_version: "8.1"
webserver_type: nginx-fpm
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
database:
    type: mariadb
    version: "10.4"
use_dns_when_possible: true
composer_version: "2"
disable_settings_management: true
web_environment: []
nodejs_version: "16"
  1. Create snapshot ddev snapshot --name main

  2. Export your database ddev export-db --gzip=false --file=main.sql (without gzip because maybe it's a bit faster :) )

  3. Destroy the old env ddev delete --omit-snapshot --yes

  4. Switch to the new mysql db in config.yaml:

    database:
    type: mysql
    version: "8.0"
  5. Init the new env: ddev start

  6. Import DB dump. ddev import-db --file=mysql8-tmp.sql

  7. Try to create snapshot again: ddev snapshot --name main

Anything else?

No response

rfay commented 1 month ago

Is it important to you to have snapshots with the same name and different database types?

hkirsman commented 1 month ago

For some time yes until this is still in branch and not yet in main. I would then be ableo to continue working with other features until that's merged. I guess it's an edge that doesn't happen that often. But I think in any case the error message should be better.

rfay commented 1 month ago

I do confirm your results:

Two snapshots with same base name, different type ``` $ ddev debug configyaml | grep database database: {mariadb 10.4} rfay@rfay-mbp-2021:~/workspace/d10$ ddev snapshot --name=myname Creating database snapshot myname Created database snapshot myname Restore this snapshot with 'ddev snapshot restore myname' rfay@rfay-mbp-2021:~/workspace/d10$ ddev debug migrate-database mysql:8.0 Is it OK to attempt conversion from mariadb:10.4 to mysql:8.0? This will export your database, create a snapshot, then destroy your current database and import into the new database type. It only migrates the 'db' database [Y/n] (yes): Wrote database dump from project 'd10' database 'db' to file /Users/rfay/workspace/d10/.ddev/.downloads/db.sql.gz in gzip format. Creating database snapshot d10_remove_data_snapshot_20240403203004 Container ddev-d10-db Stopped Container ddev-d10-web Stopped Container ddev-d10-web Stopped Container ddev-d10-db Stopped Container ddev-d10-db Removed Container ddev-d10-web Removed Network ddev-d10_default Removed Volume d10-mariadb for project d10 was deleted Volume d10-postgres for project d10 was deleted Volume d10_project_mutagen for project d10 was deleted Project d10 was deleted. Your code and configuration are unchanged. Building project images... .Project images built in 1s. Network ddev-d10_default Created Container ddev-d10-web Created Container ddev-d10-db Created Container ddev-d10-web Started Container ddev-d10-db Started Starting Mutagen sync process... ..Mutagen sync flush completed in 3s. For details on sync status 'ddev mutagen st d10 -l' Waiting for web/db containers to become ready: [web db] Starting ddev-router if necessary... Container ddev-router Running Waiting for additional project containers to become ready... All project containers are now ready. mysql: [Warning] Using a password on the command line interface can be insecure. 4.33MiB 0:00:00 [4.93MiB/s] [=========================================================================================>] 100% Database was converted to mysql:8.0 rfay@rfay-mbp-2021:~/workspace/d10$ ddev snapshot --name=myname Failed to snapshot d10: snapshot myname-mysql_8.0.gz already exists, please use another snapshot name or clean up snapshots with `ddev snapshot --cleanup` rfay@rfay-mbp-2021:~/workspace/d10$ ls -l .ddev/db_snapshots/ total 29368 -rw-r--r-- 1 rfay staff 7521618 Apr 3 20:30 d10_remove_data_snapshot_20240403203004-mariadb_10.4.gz -rw-r--r-- 1 rfay staff 7508156 Apr 3 20:29 myname-mariadb_10.4.gz rfay@rfay-mbp-2021:~/workspace/d10$ ```