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.h2;
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,7 +17,7 @@ public class H2TenantMigration extends AbstractJdbcTenantMigration {
}
@Override
protected int updateTenantId(Table<?> table, DSLContext context) {
protected int updateTenantIdField(Table<?> table, DSLContext context) {
String query = """
UPDATE "%s"
SET "value" = '{"tenantId":"%s",' || SUBSTRING("value", 2)
@@ -24,4 +26,17 @@ public class H2TenantMigration extends AbstractJdbcTenantMigration {
return context.execute(query, "main");
}
@Override
protected int updateTenantIdFieldAndKey(Table<?> table, DSLContext context) {
String query = """
UPDATE "%s"
SET
"key" = '%s_' || "key",
"value" = '{"tenantId":"%s",' || SUBSTRING("value", 2)
WHERE JQ_STRING("value", '.tenantId') IS NULL
""".formatted(table.getName(), MAIN_TENANT, MAIN_TENANT);
return context.execute(query);
}
}