Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for valid db version in ddev debug migrate-database #6168

Merged

Conversation

stasadev
Copy link
Member

@stasadev stasadev commented May 9, 2024

The Issue

$ ddev debug migrate-database mariadb:12345
Is it OK to attempt conversion from mariadb:10.11 to mariadb:12345?
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):

How This PR Solves The Issue

Fixed the condition for valid db versions. I came across it and couldn't understand how it worked before. During debugging, I saw that instead of the version, for example, 8.0, the whole string mysql:8.0 was passed inside.

Manual Testing Instructions

Automated Testing Overview

Related Issue Link(s)

Release/Deployment Notes

@stasadev stasadev requested review from a team as code owners May 9, 2024 18:32
@github-actions github-actions bot added the bugfix label May 9, 2024
Copy link

github-actions bot commented May 9, 2024

@@ -207,7 +209,7 @@ func GetValidMariaDBVersions() []string {
// IsValidPostgresVersion is a helper function to determine if a PostgreSQL version is valid, returning
// true if the supplied version is valid and false otherwise.
func IsValidPostgresVersion(v string) bool {
if _, ok := ValidPostgresVersions[v]; !ok {
if _, ok := ValidPostgresVersions[strings.TrimPrefix(v, Postgres+":")]; !ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Postgres or postgres ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postgres, this is a constant:

// Database Types
const (
MariaDB = "mariadb"
MySQL = "mysql"
Postgres = "postgres"
)

@rfay rfay added this to the v1.23.1 milestone May 10, 2024
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works perfectly and looks right. I just didn't understand the validator change.. was it always wrong???

func IsValidMariaDBVersion(MariaDBVersion string) bool {
if _, ok := ValidMariaDBVersions[MariaDBVersion]; !ok {
func IsValidMariaDBVersion(v string) bool {
if _, ok := ValidMariaDBVersions[strings.TrimPrefix(v, MariaDB+":")]; !ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So these were only used in ddev debug migrate-database and were always wrong?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right.

I didn't even know the validator was broken, the condition in ddev debug migrate-database looked strange and I investigated it.

@rfay rfay merged commit 38434d6 into ddev:master May 10, 2024
22 of 23 checks passed
@stasadev stasadev deleted the 20240509_stasadev_fix_db_version_validation branch May 10, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants