-
Notifications
You must be signed in to change notification settings - Fork 80
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
MySQL support #42
MySQL support #42
Conversation
ecto_sql supports UPSERT behaviour for both the MySQL and Postgres adapters. Postgres requires the `conflict_target` option be supplied when performing updates, while MySQL does not support it at all. To allow supporting both of these backends, we'll use the Repo's adapter to differentiate what kind of database we're talking to, and use that to generate the appropriate insert options.
Ecto Persistence: Customize UPSERT options for MySQL adapter
…ackage is not part of the application
Hi @stewart, I think that this is now working. Do you want to give it a spin? |
Thanks @tompave - this changeset works as expected in my development environment, using I'll be able to confirm more concretely once we've got it deployed to a staging environment for further testing, but I don't see any immediate problems. |
Ok. Leaving this here for the moment till you can confirm it works in a deployed env. |
Hi @stewart, any update on this? |
I apologize, but we're still waiting for the go-ahead for a staging deploy, which should happen tomorrow. In local development, my team has not seen any issues with this branch. I also noted the most recent release of |
Still haven't gotten a green-light for our planned staging deploy, unfortunately - it's currently scheduled for tomorrow. In the interest of keeping this PR moving, I've manually verified the MySQL persistence strategy for both the boolean and percentage-gate flags works as expected on both MySQL 5.7.25 and MariaDB 10.3.14, using both the I additionally attempted to test with MySQL 8.0 and
Everything looks good to me. |
Thanks for running those tests. 👍 |
Can also confirm this branch is behaving as expected in our staging environments. Thank you for the additional MySQL support changes, and your patience with our slow turn-around for testing them. |
Cool, thanks for confirming it. 👍 This is now on master. Before releasing a new version, I want to add some more documentation and changelog entries, and I want to verify that everything still works with both |
Ok, released on Hex.pm as v1.3.0 |
This branch tracks the progress to add support for MySQL to the Ecto persistence adapter, which currently only works with PostgreSQL.
The current status is that this branch contains some changes to work with MySQL on local dev and test, as well as on CI.
The builds still fail with MySQL because of how the table is locked using the Postgres syntax(solved)IN SHARE ROW EXCLUSIVE MODE
, which MySQL doesn't understand. MySQL also seems to have different guarantees in terms of table locks within transactions (docs), which makes adapting the logic not straightforward.The table lock is required because the unique three-column index alone wouldn't prevent duplicated rows for the percentage gates. A different table design would make the table lock not necessary, but when I added the percentage gates I was mainly concerned with keeping it a small and retro-compatible version update. Perhaps it's something I could revisit for version 2.0, but I don't have any concrete plan at the moment.
Thank you @stewart for starting this work by raising issue #40 and working on the first fix, with PR #41.