fix(core): tenant migration scripts now update keys

* chore(core): add keyboard shortcuts icon to flow editor tab (#8925)

fix(core): don't send empty operations when migrating roles (#3807)

Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io>

* fix(core): migrate key that required tenant id to avoid duplication

---------

Co-authored-by: Miloš Paunović <paun992@hotmail.com>
Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io>
This commit is contained in:
Nicolas K.
2025-05-23 16:44:53 +02:00
committed by GitHub
parent 2601df3de2
commit 29c3bd7dec
4 changed files with 74 additions and 10 deletions

View File

@@ -1,5 +1,7 @@
package io.kestra.repository.mysql;
import static io.kestra.core.tenant.TenantService.MAIN_TENANT;
import io.kestra.jdbc.JooqDSLContextWrapper;
import io.kestra.jdbc.repository.AbstractJdbcTenantMigration;
import jakarta.inject.Singleton;
@@ -15,11 +17,24 @@ public class MysqlTenantMigration extends AbstractJdbcTenantMigration {
}
@Override
protected int updateTenantId(Table<?> table, DSLContext context) {
protected int updateTenantIdField(Table<?> table, DSLContext context) {
String query = "UPDATE `" + table.getName() + "` " +
"SET `value` = JSON_SET(`value`, '$.tenantId', ?) " +
"WHERE JSON_UNQUOTE(JSON_EXTRACT(`value`, '$.tenantId')) IS NULL";
return context.execute(query, "main");
return context.execute(query, MAIN_TENANT);
}
@Override
protected int updateTenantIdFieldAndKey(Table<?> table, DSLContext context) {
String query = """
UPDATE `%s`
SET
`key` = CONCAT(?, '_', `key`),
`value` = JSON_SET(`value`, '$.tenantId', ?)
WHERE JSON_UNQUOTE(JSON_EXTRACT(`value`, '$.tenantId')) IS NULL
""".formatted(table.getName());
return context.execute(query, MAIN_TENANT, MAIN_TENANT);
}
}