fix: Reconnect application showing for existing datasources due to missing flag value (#12034)
* Add migration to fix the reconnect application showing for existing datasources * Changes per review * Check the invalids before adding the configured flag * Fix NPE in migration * Refactor Co-authored-by: Abhijeet <abhijeet@appsmith.com>
This commit is contained in:
parent
1ca9fd803a
commit
e44a81e031
|
|
@ -258,6 +258,7 @@ public class GitFileUtils {
|
|||
// Don't commit application name as while importing we are using the repoName as application name
|
||||
application.setName(null);
|
||||
application.setPublishedPages(null);
|
||||
application.setSlug(null);
|
||||
}
|
||||
|
||||
private void removeUnwantedFieldsFromDatasource(Datasource datasource) {
|
||||
|
|
|
|||
|
|
@ -5073,5 +5073,4 @@ public class DatabaseChangelog {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.appsmith.server.migrations;
|
||||
|
||||
import com.appsmith.external.models.Datasource;
|
||||
import com.appsmith.external.models.Property;
|
||||
import com.appsmith.external.models.QDatasource;
|
||||
import com.appsmith.server.domains.NewAction;
|
||||
import com.appsmith.server.domains.Plugin;
|
||||
import com.appsmith.server.domains.QNewAction;
|
||||
|
|
@ -27,6 +29,7 @@ import java.util.regex.Pattern;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.appsmith.server.repositories.BaseAppsmithRepositoryImpl.fieldName;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static org.springframework.data.mongodb.core.query.Criteria.where;
|
||||
import static org.springframework.data.mongodb.core.query.Query.query;
|
||||
|
||||
|
|
@ -609,5 +612,30 @@ public class DatabaseChangelog2 {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert isConfigured boolean to check if the datasource is correctly configured. This field will be used during
|
||||
* the file or git import to maintain the datasource configuration state
|
||||
*
|
||||
* @param mongockTemplate
|
||||
*/
|
||||
@ChangeSet(order = "004", id = "add-isConfigured-flag-for-all-datasources", author = "")
|
||||
public void updateIsConfiguredFlagForAllTheExistingDatasources(MongockTemplate mongockTemplate) {
|
||||
final Query datasourceQuery = query(where(fieldName(QDatasource.datasource.deleted)).ne(true))
|
||||
.addCriteria(where(fieldName(QDatasource.datasource.invalids)).size(0));
|
||||
datasourceQuery.fields()
|
||||
.include(fieldName(QDatasource.datasource.id));
|
||||
|
||||
List<Datasource> datasources = mongockTemplate.find(datasourceQuery, Datasource.class);
|
||||
for(Datasource datasource: datasources) {
|
||||
final Update update = new Update();
|
||||
update.set(fieldName(QDatasource.datasource.isConfigured), TRUE);
|
||||
mongockTemplate.updateFirst(
|
||||
query(where(fieldName(QDatasource.datasource.id)).is(datasource.getId())),
|
||||
update,
|
||||
Datasource.class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user