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