mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-25 02:14:38 -05:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user