feat(core): #3427 add OSS tenant migration scripts (#8798)

* feat(core): #3427 add OSS tenant migration scripts

* clean(core): fixes after review

* clean(core): make only one command for oss and EE migration

* fix(core): user synchronisation command and clean PR

---------

Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io>
This commit is contained in:
Nicolas K.
2025-05-19 16:42:59 +02:00
committed by GitHub
parent 9cdc3c54a3
commit 734fcbc45b
9 changed files with 271 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package io.kestra.repository.h2;
import io.kestra.jdbc.JooqDSLContextWrapper;
import io.kestra.jdbc.repository.AbstractJdbcTenantMigration;
import jakarta.inject.Singleton;
import org.jooq.DSLContext;
import org.jooq.Table;
@Singleton
@H2RepositoryEnabled
public class H2TenantMigration extends AbstractJdbcTenantMigration {
protected H2TenantMigration(JooqDSLContextWrapper dslContextWrapper) {
super(dslContextWrapper);
}
@Override
protected int updateTenantId(Table<?> table, DSLContext context) {
String query = """
UPDATE "%s"
SET "value" = '{"tenantId":"%s",' || SUBSTRING("value", 2)
WHERE JQ_STRING("value", '.tenantId') IS NULL
""".formatted(table.getName(), "main");
return context.execute(query, "main");
}
}