Skip to content

Commit 75a2963

Browse files
fix: deprecate latest in app store app version (#4896)
* fix: deprecate latest flag from app_store application_version and increase varchar len for some columns * fix: deprecate latest flag from app_store application_version and increase varchar len for some columns * fix: remove digest column length update
1 parent da91acb commit 75a2963

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

pkg/appStore/discover/repository/AppStoreApplicationVersionRepository.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package appStoreDiscoverRepository
1919

2020
import (
21+
"fmt"
2122
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
2223
"github.com/devtron-labs/devtron/pkg/sql"
2324
"github.com/go-pg/pg"
@@ -114,27 +115,33 @@ func updateFindWithFilterQuery(filter *appStoreBean.AppStoreFilter, updateAction
114115
query = " ch.name as chart_name, das.id as docker_artifact_store_id"
115116
}
116117
}
118+
119+
latestAppStoreVersionQuery := " SELECT MAX(asv.id) as id " +
120+
" FROM app_store_application_version asv " +
121+
" INNER JOIN app_store aps ON (asv.app_store_id = aps.id and aps.active = true) " +
122+
" GROUP BY asv.app_store_id "
123+
117124
if updateAction == QUERY_JOIN_UPDTAE {
118125
if len(filter.ChartRepoId) > 0 && len(filter.RegistryId) > 0 {
119126
query = " LEFT JOIN chart_repo ch ON (aps.chart_repo_id = ch.id and ch.deleted IS FALSE)" +
120127
" LEFT JOIN docker_artifact_store das ON aps.docker_artifact_store_id = das.id" +
121128
" LEFT JOIN oci_registry_config oci ON oci.docker_artifact_store_id = das.id" +
122-
" WHERE (asv.latest IS TRUE AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))" +
129+
fmt.Sprintf(" WHERE (asv.id IN (%s) AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))", latestAppStoreVersionQuery) +
123130
" AND (ch.id IN (?) OR das.id IN (?))"
124131
} else if len(filter.RegistryId) > 0 {
125132
query = " LEFT JOIN docker_artifact_store das ON aps.docker_artifact_store_id = das.id" +
126133
" LEFT JOIN oci_registry_config oci ON oci.docker_artifact_store_id = das.id" +
127-
" WHERE asv.latest IS TRUE AND (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)" +
134+
fmt.Sprintf(" WHERE asv.id IN (%s) AND (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)", latestAppStoreVersionQuery) +
128135
" AND das.id IN (?)"
129136
} else if len(filter.ChartRepoId) > 0 {
130137
query = " LEFT JOIN chart_repo ch ON (aps.chart_repo_id = ch.id and ch.deleted IS FALSE)" +
131-
" WHERE asv.latest IS TRUE AND ch.active IS TRUE" +
138+
fmt.Sprintf(" WHERE asv.id IN (%s) AND ch.active IS TRUE", latestAppStoreVersionQuery) +
132139
" AND ch.id IN (?)"
133140
} else {
134141
query = " LEFT JOIN chart_repo ch ON (aps.chart_repo_id = ch.id and ch.deleted IS FALSE)" +
135142
" LEFT JOIN docker_artifact_store das ON aps.docker_artifact_store_id = das.id" +
136143
" LEFT JOIN oci_registry_config oci ON oci.docker_artifact_store_id = das.id" +
137-
" WHERE (asv.latest IS TRUE AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))"
144+
fmt.Sprintf(" WHERE (asv.id IN (%s) AND (ch.active IS TRUE OR (das.active IS TRUE AND oci.deleted IS FALSE AND oci.is_chart_pull_active IS TRUE)))", latestAppStoreVersionQuery)
138145
}
139146
}
140147
return query
@@ -249,7 +256,7 @@ func (impl *AppStoreApplicationVersionRepositoryImpl) FindByAppStoreName(name st
249256

250257
func (impl *AppStoreApplicationVersionRepositoryImpl) SearchAppStoreChartByName(chartName string) ([]*appStoreBean.ChartRepoSearch, error) {
251258
var chartRepos []*appStoreBean.ChartRepoSearch
252-
//eryTemp := "select asv.version, asv.icon,asv.deprecated ,asv.id as app_store_application_version_id, aps.*, ch.name as chart_name from app_store_application_version asv inner join app_store aps on asv.app_store_id = aps.id inner join chart_repo ch on aps.chart_repo_id = ch.id where asv.latest is TRUE order by aps.name asc;"
259+
// eryTemp := "select asv.version, asv.icon,asv.deprecated ,asv.id as app_store_application_version_id, aps.*, ch.name as chart_name from app_store_application_version asv inner join app_store aps on asv.app_store_id = aps.id inner join chart_repo ch on aps.chart_repo_id = ch.id where asv.latest is TRUE order by aps.name asc;"
253260
queryTemp := "select asv.id as app_store_application_version_id, asv.version, asv.deprecated, aps.id as chart_id," +
254261
" aps.name as chart_name, chr.id as chart_repo_id, chr.name as chart_repo_name" +
255262
" from app_store_application_version asv" +
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TABLE app_store_application_version ALTER COLUMN "icon" TYPE VARCHAR(250);
2+
ALTER TABLE app_store_application_version ALTER COLUMN "source" TYPE VARCHAR(250);
3+
ALTER TABLE app_store_application_version ALTER COLUMN "home" TYPE VARCHAR(100);
4+
ALTER TABLE app_store_application_version ALTER COLUMN "name" TYPE VARCHAR(100);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TABLE app_store_application_version ALTER COLUMN "icon" TYPE VARCHAR(512);
2+
ALTER TABLE app_store_application_version ALTER COLUMN "source" TYPE VARCHAR(512);
3+
ALTER TABLE app_store_application_version ALTER COLUMN "home" TYPE VARCHAR(256);
4+
ALTER TABLE app_store_application_version ALTER COLUMN "name" TYPE VARCHAR(256);

0 commit comments

Comments
 (0)