Fix/tutorial flows with migration (#9620)

* fix(core): #9609 delete tutorial flows and triggers before migrating the database

* fix(core): #9609 delete tutorial flows and triggers before migrating the database for EE version

---------

Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io>
This commit is contained in:
Nicolas K.
2025-06-19 10:53:18 +02:00
committed by GitHub
parent 9c052c0a41
commit 7fc274fe1a
2 changed files with 23 additions and 0 deletions

View File

@@ -39,4 +39,13 @@ public class H2TenantMigration extends AbstractJdbcTenantMigration {
return context.execute(query);
}
@Override
protected int deleteTutorialFlows(Table<?> table, DSLContext context) {
String query = """
DELETE FROM "%s"
WHERE JQ_STRING("value", '.namespace') = ?
""".formatted(table.getName());
return context.execute(query, "tutorial");
}
}

View File

@@ -45,6 +45,15 @@ public abstract class AbstractJdbcTenantMigration implements TenantMigrationInte
}
if (!dryRun) {
if ("flows".equalsIgnoreCase(table.getName()) || "triggers".equalsIgnoreCase(table.getName())){
log.info("🔸 Delete tutorial flows to prevent duplication");
int deleted = dslContextWrapper.transactionResult(configuration -> {
DSLContext context = DSL.using(configuration);
return deleteTutorialFlows(table, context);
});
log.info("✅ {} tutorial flows have been deleted", deleted);
}
int updated;
if (tableWithKey(table.getName())){
updated = dslContextWrapper.transactionResult(configuration -> {
@@ -93,4 +102,9 @@ public abstract class AbstractJdbcTenantMigration implements TenantMigrationInte
protected abstract int updateTenantIdFieldAndKey(Table<?> table, DSLContext context);
protected int deleteTutorialFlows(Table<?> table, DSLContext context){
String query = "DELETE FROM %s WHERE namespace = ?".formatted(table.getName());
return context.execute(query, "tutorial");
}
}