We've been using kratos and hydra in our project f...
# ory-selfhosting
w
We've been using kratos and hydra in our project for a long time. Up until now, that has been with mariadb as the database. That's not supported by ory though, and since a while hydra cannot upgrade because of that, so we're now attempting to switch to mysql instead. Ironically however, kratos doesn't work with mysql. Specifically, a fresh kratos install fails to apply its initial (auto)migrations against mysql:
Copy code
error executing migrations/sql/20210817181232000006_unique_credentials.mysql.up.sql, sql: ALTER TABLE `identity_credential_identifiers` MODIFY `identity_credential_type_id` char(36) NOT NULL;: Error 1832 (HY000): Cannot change column 'identity_credential_type_id': used in a foreign key constraint 'identity_credential_identifiers_type_id_fk_idx'
This is with mysql running in docker:
<http://docker.io/bitnami/mysql:8.4.2-debian-12-r4|docker.io/bitnami/mysql:8.4.2-debian-12-r4>
and a fresh empty database. I found an issue about this, and the recommended solution is to set mysql's
sql_mode
to
TRADITIONAL
. I tried that by setting the env var
MYSQL_EXTRA_FLAGS
to
--sql-mode=TRADITIONAL
, but the kratos error remains. Any suggestions? I feel like I must be missing something because I expect many kratos users use mysql.
m
Hello Arie, sorry don't have experience with this particular issue... In any case if you don't get an answer here in time, you can also open a discussion on the repo in GitHub - you can also search the Slack archive https://archive.ory.sh/ maybe it came up before.
Ory also offers professional support, including for migrations - this is a yearly support agreement. If that would be an option please reach out here.
w
Thanks for your reply. I already opened a discussion as I'm not sure it's an issue with kratos or with our (database) settings -- even though we didn't really set anything, it's default mysql -- but that remained unanswered so far. I'll bring up the possibility of a support contract with my employer; it sounds good to me but I'm not sure if we have budget for that.
Ah I found one other person with this problem in the archive (link). They solved it by changing the migration (adding
SET FOREIGN_KEY_CHECKS = 0;
), but that would be very cumbersome in our automatically provisioned fleet of instances, we'd probably have to build our own kratos docker images and keep those updated.
Any chance to add that to the old migration in the kratos repo, if I open an issue?
m
You can definitely open an issue, but to manage expectations maintainers will probably not have time to work on it at least this year, as it does not seem to affect a lot of users overall and none of the customers. Getting some kind of support agreement imo is a good long-term option to enable Ory maintainers to work on your issues/feature requests/critical incidents.
w
Okay, thanks Vincent for the honest setting of expectations!
Ah there was a
sql_mode=''
in our template for the dsn setting for kratos, removing that fixed it. That setting was no problem with mariadb -- in fact it was presumably necessary at some point in time -- but it is with mysql.