Skip to content

chore: release target installations scripts #6529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions internal/sql/repository/pipelineConfig/PipelineRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ type PipelineRepository interface {
FindDeploymentAppTypeByIds(ids []int) (pipelines []*Pipeline, err error)
GetAllAppsByClusterAndDeploymentAppType(clusterIds []int, deploymentAppName string) ([]*PipelineDeploymentConfigObj, error)
GetAllArgoAppInfoByDeploymentAppNames(deploymentAppNames []string) ([]*PipelineDeploymentConfigObj, error)
FindEnvIdsByIdsInIncludingDeleted(ids []int) ([]int, error)
}

type CiArtifactDTO struct {
Expand Down Expand Up @@ -951,3 +952,18 @@ func (impl *PipelineRepositoryImpl) GetAllArgoAppInfoByDeploymentAppNames(deploy
Select(&result)
return result, err
}

func (impl *PipelineRepositoryImpl) FindEnvIdsByIdsInIncludingDeleted(ids []int) ([]int, error) {
var envIds []int
if len(ids) == 0 {
return envIds, nil
}
err := impl.dbConnection.Model(&Pipeline{}).
Column("pipeline.environment_id").
Where("pipeline.id in (?)", pg.In(ids)).
Select(&envIds)
if err != nil {
impl.logger.Errorw("error on fetching pipelines", "ids", ids, "err", err)
}
return envIds, err
}
241 changes: 241 additions & 0 deletions scripts/sql/33203600_target_installations.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
BEGIN;

DELETE FROM global_policy where policy_of = 'RELEASE_ACTION_CHECK' AND version = 'V2';
-- reverting to old state
DROP INDEX IF EXISTS idx_unique_policy_name_policy_of_version;
-- reverting to old state
CREATE UNIQUE INDEX idx_unique_policy_name_policy_of
ON global_policy (name,policy_of)
WHERE deleted = false;

UPDATE devtron_resource_schema set schema = '{
"type": "object",
"title": "Release Schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required":
[
"version",
"kind",
"overview",
"status"
],
"properties":
{
"kind":
{
"const": "release"
},
"status":
{
"type": "object",
"required":
[
"config"
],
"properties":
{
"config":
{
"type": "object",
"required":
[
"status"
],
"properties":
{
"lock":
{
"type": "boolean"
},
"status":
{
"enum":
[
"draft",
"readyForRelease",
"hold"
],
"type": "string"
}
}
}
}
},
"version":
{
"enum":
[
"alpha1"
],
"type": "string"
},
"overview":
{
"type": "object",
"required":
[
"id",
"releaseVersion"
],
"properties":
{
"id":
{
"type": "number"
},
"icon":
{
"type": "string",
"contentEncoding": "base64"
},
"name":
{
"type": "string"
},
"note":
{
"type": "string"
},
"tags":
{
"additionalProperties":
{
"type": "string"
}
},
"idType":
{
"enum":
[
"resourceObjectId",
"oldObjectId"
],
"type": "string",
"description": "for existing resources in the system we keep original ids of their tables in id field. Like id of apps table is kept for devtron applications. But in release we keep data as devtron resource only. To differ between nature of these two types of id values."
},
"metadata":
{
"type": "object",
"required":
[
"Type of release",
"Release Managers",
"On-Duty"
],
"properties":
{
"On-Duty":
{
"type": "array",
"items":
{
"type": "object",
"refType": "#/references/users"
},
"minItems": 1,
"uniqueItems": true
},
"Milestones":
{
"type": "object",
"properties":
{
"Release end date":
{
"type": "string",
"format": "date"
},
"30% milestone date":
{
"type": "string",
"format": "date"
},
"70% milestone date":
{
"type": "string",
"format": "date"
},
"Release planned start date":
{
"type": "string",
"format": "date"
}
}
},
"Type of release":
{
"enum":
[
"Major",
"Minor",
"Patch"
],
"type": "string"
},
"Release Managers":
{
"type": "array",
"items":
{
"type": "object",
"refType": "#/references/users"
},
"minItems": 1,
"uniqueItems": true
},
"Target customers":
{
"type": "array",
"items":
{
"type": "string"
},
"uniqueItems": true
},
"Released customers":
{
"type": "array",
"items":
{
"type": "string"
},
"uniqueItems": true
}
}
},
"createdBy":
{
"type": "object",
"refType": "#/references/users"
},
"createdOn":
{
"type": "string"
},
"description":
{
"type": "string"
},
"releaseVersion":
{
"type": "string"
},
"firstReleasedOn":
{
"type": "string",
"format": "date-time"
}
}
},
"taskMapping":
{
"type": "array"
},
"dependencies":
{
"type": "array"
}
}
}' where devtron_resource_id=(select id from devtron_resource where kind = 'release');

COMMIT;
Loading