-
-
Notifications
You must be signed in to change notification settings - Fork 4
Switch to MySQL 8 #103
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
base: main
Are you sure you want to change the base?
Switch to MySQL 8 #103
Conversation
With this Local Beach uses MySQL 8 instead of MariaDB 10 to be closer to the setup used in Beach. Running `beach setup` will migrate all databases from MariaDB to MySQL if the path used previously exists.
2660e85 to
da4db23
Compare
|
Test run result: |
|
When testing, build this, run |
I'll check what's going wrong here … |
|
Sorry, I didn't compile with The setup run worked now: However, directly after the run, mariadb is still running: |
|
Hm… you did not do |
|
|
|
Ah, SSL is disabled, I have it set to preferred… ✅ |
Or maybe even do a down before and tell people to run start afterwards? |
Wouldn't it be safe to run "down" and "start" (or just down) after the setup migrated the databases? |
Thanks, it works now with SSL set to "preferred". |
The success message was always output, even when no migration was done.
|
I just wondered, how this behaves if people do not run setup… it will probably lead to all databases seem to be gone. Maybe we can add a check to the brew formula to output a hint when updating to a version greater than "last version using MariaDB"? Ah, wait – does |
|
The setup runs automagically… when the "base" does not exist. So when upgrading, it will not run and people will have panic attacks due to "missing" databases (since MySQL will not have any data copied over). |
- Add migration marker file to prevent re-running - Improve error handling with defer cleanup - Add progress indicators for each step - Add verification before suggesting data deletion
- Change bringBeachDown() to return error instead of bool - Consolidate compose file writing into writeComposeFile() - Update all callers to properly handle errors
Remove all DEFAULT clauses from JSON/TEXT/BLOB columns instead of trying to convert them, as MySQL 8.0 doesn't support default values for these column types in the same way as MariaDB. Handles both quoted strings and function calls like json_object().
|
Now, with these additions, Local Beach successfully migrated all of my databases and showed some progress while doing it. |
kdambekalns
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice with the progress and verification!
But of course I have something to complain about… 🙈
| if err == nil { | ||
| log.Info("Migrating MariaDB data from " + path.MariaDBDatabase + " to MySQL at " + path.MySQLDatabase) | ||
| log.Warn("Note: This may take a while, depending on DB size!") | ||
| migrationMarkerPath := filepath.Join(path.Base, ".mariadb-to-mysql-migration-complete") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe put that into the MariaDB folder, so it is gone when the source has been removed? Or move it into the block that is run when there is MariaDB data to (potentially) migrate…
Otherwise the setup will always say the migration was completed, until the marker is removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea!
| if err != nil { | ||
| // No MariaDB data to migrate | ||
| if os.IsNotExist(err) { | ||
| log.Debug("No MariaDB data found, skipping migration") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, yes. But that will be shown for every setup run ever after… and even for someone who never even had MariaDB in her Local Beach setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let's remove that, it doesn't make sense.
|
|
||
| // Start Local Beach after setup/migration | ||
| log.Info("Starting Local Beach...") | ||
| err = startLocalBeach() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that work when it's not run in a Local Beach instance? I could imagine that when people run brew upgrade they might be in e.g. their $HOME…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did work for me when I ran the beach setup in the Local Beach / Go project directory. So, there was no Local Beach project within reach.
| log.Info(fmt.Sprintf(" [%d/%d] Migrating database: %s", i+1, len(databaseList), database)) | ||
| commandArgs = []string{"exec", "local_beach_database", "bash", "-c"} | ||
| commandArgs = append(commandArgs, "mysqldump -h local_beach_mariadb -u root -ppassword --add-drop-trigger --compress --comments --dump-date --hex-blob --quote-names --routines --triggers --no-autocommit --no-tablespaces --skip-lock-tables --single-transaction --quick --databases "+database+" | sed -e \"s/DEFAULT '{}' COMMENT '(DC2Type:json)'/DEFAULT (JSON_OBJECT()) COMMENT '(DC2Type:json)'/\" | mysql -h local_beach_database -u root -ppassword") | ||
| // Remove DEFAULT clauses from JSON/TEXT/BLOB columns for MariaDB→MySQL 8.0 compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this… it makes the migration work, but:
- using
sedon SQL might be doing very weird things - it will not fix the code that created incompatible SQL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question is how we can fail gracefully then, with a meaningful error message? And you started the sed thing, didn't you?
|
Let's let that sink in and also try to find a solution for the "setup isn't even run" scenario. No need to hurry now… |




With this Local Beach uses MySQL 8 instead of MariaDB 10 to be closer to the setup used in Beach.
Running
beach setupwill migrate all databases from MariaDB to MySQL if the path used previously exists.