Skip to content

Commit 46e941a

Browse files
fix: Rename migration seq (#6024)
* migration seq rename * migration seq fix and renamed
1 parent 5f3e842 commit 46e941a

10 files changed

+192
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TABLE roles DROP COLUMN "release";
2+
ALTER TABLE roles DROP COLUMN "release_track";
3+
DELETE from rbac_role_resource_detail where resource in ('release','release-track');
4+
DELETE from rbac_policy_resource_detail where resource in ('release','release-track');
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions",
3+
"resource_object", "eligible_entity_access_types", "deleted", "created_on",
4+
"created_by", "updated_on", "updated_by")
5+
VALUES ('release', '{"value": "release", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%/%", "indexKeyMap": {"0": "ReleaseTrackObj", "2": "ReleaseObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1);
6+
7+
INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions",
8+
"resource_object", "eligible_entity_access_types", "deleted", "created_on",
9+
"created_by", "updated_on", "updated_by")
10+
VALUES ('release-requirement', '{"value": "release-requirement", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%/%", "indexKeyMap": {"0": "ReleaseTrackObj", "2": "ReleaseObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1);
11+
12+
INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions",
13+
"resource_object", "eligible_entity_access_types", "deleted", "created_on",
14+
"created_by", "updated_on", "updated_by")
15+
VALUES ('release-track', '{"value": "release-track", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%", "indexKeyMap": {"0": "ReleaseTrackObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1);
16+
17+
INSERT INTO rbac_policy_resource_detail ("resource", "policy_resource_value", "allowed_actions",
18+
"resource_object", "eligible_entity_access_types", "deleted", "created_on",
19+
"created_by", "updated_on", "updated_by")
20+
VALUES ('release-track-requirement', '{"value": "release-track-requirement", "indexKeyMap": {}}', ARRAY['get','update','create','delete','patch'],'{"value": "%", "indexKeyMap": {"0": "ReleaseTrackObj"}}', ARRAY['release'],'f','now()', 1, 'now()', 1);
21+
22+
23+
24+
25+
26+
INSERT INTO rbac_role_resource_detail ("resource", "role_resource_key", "role_resource_update_key",
27+
"eligible_entity_access_types", "deleted", "created_on", "created_by",
28+
"updated_on", "updated_by")
29+
VALUES ('release', 'Release', 'Release', ARRAY ['release'], false, now(), 1, now(), 1);
30+
31+
32+
INSERT INTO rbac_role_resource_detail ("resource", "role_resource_key", "role_resource_update_key",
33+
"eligible_entity_access_types", "deleted", "created_on", "created_by",
34+
"updated_on", "updated_by")
35+
VALUES ('release-track', 'ReleaseTrack', 'ReleaseTrack', ARRAY ['release'], false, now(), 1, now(), 1);
36+
37+
38+
39+
40+
ALTER TABLE roles ADD COLUMN IF NOT EXISTS "release" text;
41+
ALTER TABLE roles ADD COLUMN IF NOT EXISTS "release_track" text;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE notification_settings DROP COLUMN IF EXISTS cluster_id INT;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE notification_settings drop constraint IF EXISTS notification_settings_env_id_fkey;
2+
ALTER TABLE notification_settings ADD COLUMN IF NOT EXISTS cluster_id INT;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Drop the message column from the "public"."installed_app_version_history" table
2+
ALTER TABLE "public"."installed_app_version_history"
3+
DROP COLUMN IF EXISTS message;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Add message column to "public"."installed_app_version_history" table
2+
ALTER TABLE "public"."installed_app_version_history"
3+
ADD COLUMN IF NOT EXISTS message TEXT;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DELETE FROM plugin_step_variable WHERE plugin_step_id=(SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger');
2+
DELETE FROM plugin_step where plugin_id=(SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger');
3+
DELETE FROM plugin_pipeline_script where id=(SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger');
4+
DELETE FROM plugin_stage_mapping where plugin_id=(SELECT id from plugin_metadata where name='Devtron CI Trigger');
5+
DELETE FROM plugin_metadata where name='Devtron CI Trigger';
6+
UPDATE plugin_metadata SET is_latest = true WHERE id = (SELECT id FROM plugin_metadata WHERE name= 'Devtron CI Trigger v1.0.0' and is_latest= false);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
UPDATE plugin_metadata SET is_latest = false WHERE id = (SELECT id FROM plugin_metadata WHERE name= 'Devtron CI Trigger v1.0.0' and is_latest= true);
2+
3+
INSERT INTO "plugin_metadata" ("id", "name", "description","deleted", "created_on", "created_by", "updated_on", "updated_by","plugin_parent_metadata_id","plugin_version","is_deprecated","is_latest")
4+
VALUES (nextval('id_seq_plugin_metadata'), 'Devtron CI Trigger','Triggers the CI pipeline of Devtron Application','f', 'now()', 1, 'now()', 1, (SELECT id FROM plugin_parent_metadata WHERE identifier='devtron-ci-trigger-v1-0-0'),'1.1.0', false, true);
5+
6+
INSERT INTO "plugin_stage_mapping" ("plugin_id","stage_type","created_on", "created_by", "updated_on", "updated_by")
7+
VALUES ((SELECT id FROM plugin_metadata WHERE plugin_version='1.1.0' and name='Devtron CI Trigger' and deleted= false),0,'now()', 1, 'now()', 1);
8+
9+
INSERT INTO "plugin_pipeline_script" ("id", "script","type","deleted","created_on", "created_by", "updated_on", "updated_by")VALUES (
10+
nextval('id_seq_plugin_pipeline_script'),
11+
E'#!/bin/sh
12+
docker run -e DevtronApiToken=$DevtronApiToken -e DevtronEndpoint=$DevtronEndpoint -e DevtronApp=$DevtronApp -e CiPipeline=$CiPipeline -e DevtronEnv=$DevtronEnv -e GitCommitHash=$GitCommitHash -e Timeout=$Timeout -e IgnoreCache=$IgnoreCache --name devtron-ci-trigger quay.io/devtron/devtron-utils:ci-trigger-plugin-v1.1.0
13+
exit_code=$?
14+
if [ $ExitOnFail == true ];then
15+
if [ $exit_code == 2 ];then
16+
echo "The triggered build has been failed terminating the current process."
17+
exit $exit_code
18+
fi
19+
fi
20+
if [ $exit_code -ne 0 ] && [ $exit_code -ne 2 ] ; then
21+
echo "The Docker container exited with code $exit_code. Terminating current process."
22+
exit $exit_code
23+
fi','SHELL','f','now()',1,'now()',1);
24+
25+
26+
INSERT INTO "plugin_step" ("id", "plugin_id","name","description","index","step_type","script_id","deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES (nextval('id_seq_plugin_step'), (SELECT id FROM plugin_metadata WHERE name='Devtron CI Trigger'),'Step 1','Runnig the plugin','1','INLINE',(SELECT last_value FROM id_seq_plugin_pipeline_script),'f','now()', 1, 'now()', 1);
27+
28+
INSERT INTO plugin_step_variable (id,plugin_step_id,name,format, description,is_exposed,allow_empty_value,default_value,value,variable_type,value_type,previous_step_index,variable_step_index,variable_step_index_in_plugin,reference_variable_name,deleted,created_on,created_by,updated_on,updated_by)VALUES
29+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronApiToken','STRING','Enter Devtron API Token with required permissions.','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
30+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronEndpoint','STRING','Enter the URL of Devtron Dashboard for.eg (https://devtron.example.com).','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
31+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronApp','STRING','Enter the name or ID of the Application whose build is to be triggered.','t','f',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
32+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'DevtronEnv','STRING','Enter the name or ID of the Environment to which the CI is attached. Required if CiPipeline is not given.','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
33+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'CiPipeline','STRING','Enter the name or ID of the CI pipeline to be triggered. Required if DevtronEnv is not given.','t','t',null,null,'INPUT','NEW',null,1,null,null, 'f','now()',1,'now()',1),
34+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'GitCommitHash','STRING','Enter the commit hash from which the build is to be triggered. If not given then will pick the latest.','t','t',null,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
35+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'Timeout','NUMBER','Enter the maximum time to wait for the build status.', 't','t',-1,null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1),
36+
(nextval('id_seq_plugin_step_variable'),(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Devtron CI Trigger' and ps."index"=1 and ps.deleted=false),'IgnoreCache','STRING','Set true if you want to ignore cache for the build.', 't','t','false',null,'INPUT','NEW',null,1,null,null,'f','now()',1,'now()',1);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
DELETE FROM plugin_step_variable WHERE plugin_step_id in (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.plugin_version='1.0.0' and p.name='Docker Lint' and p.deleted=false and ps."index"=1 and ps.deleted=false);
2+
3+
4+
DELETE FROM plugin_step WHERE plugin_id = (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false);
5+
6+
7+
DELETE FROM plugin_stage_mapping WHERE plugin_id =(SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false);
8+
9+
10+
DELETE FROM plugin_tag_relation WHERE plugin_id in (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false);
11+
12+
DELETE FROM pipeline_stage_step_variable where pipeline_stage_step_id in (select id from pipeline_stage_step where name = 'Docker Lint') ;
13+
14+
DELETE FROM pipeline_stage_step where ref_plugin_id in (SELECT id from plugin_metadata WHERE plugin_version='1.0.0' and name ='Docker Lint' and deleted=false);
15+
16+
17+
DELETE from plugin_pipeline_script where id = (SELECT script_id from plugin_step WHERE plugin_id=(SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted=false));
18+
19+
20+
DELETE FROM plugin_metadata WHERE plugin_version='1.0.0' and name ='Docker Lint' and deleted=false;
21+
22+
23+
DELETE FROM plugin_parent_metadata WHERE identifier ='docker-lint';
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
INSERT INTO "plugin_parent_metadata" ("id", "name","identifier", "description","type","icon","deleted", "created_on", "created_by", "updated_on", "updated_by")
2+
VALUES (nextval('id_seq_plugin_parent_metadata'), 'Docker Lint','docker-lint','This is used to analyze the Dockerfile and offer suggestions for improvements','PRESET','https://raw.githubusercontent.com/devtron-labs/devtron/main/assets/hadolint.png','f', 'now()', 1, 'now()', 1);
3+
4+
5+
UPDATE plugin_metadata SET is_latest = false WHERE id = (SELECT id FROM plugin_metadata WHERE name= 'Docker Lint' and is_latest= true);
6+
7+
8+
INSERT INTO "plugin_metadata" ("id", "name", "description","deleted", "created_on", "created_by", "updated_on", "updated_by","plugin_parent_metadata_id","plugin_version","is_deprecated","is_latest")
9+
VALUES (nextval('id_seq_plugin_metadata'), 'Docker Lint','This is used to analyze the Dockerfile and offer suggestions for improvements','f', 'now()', 1, 'now()', 1, (SELECT id FROM plugin_parent_metadata WHERE identifier='docker-lint'),'1.0.0', false, true);
10+
11+
12+
INSERT INTO "plugin_tag_relation" ("id", "tag_id", "plugin_id", "created_on", "created_by", "updated_on", "updated_by")
13+
VALUES (nextval('id_seq_plugin_tag_relation'),(SELECT id FROM plugin_tag WHERE name='Security') , (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),'now()', 1, 'now()', 1);
14+
15+
16+
INSERT INTO "plugin_tag_relation" ("id", "tag_id", "plugin_id", "created_on", "created_by", "updated_on", "updated_by")
17+
VALUES (nextval('id_seq_plugin_tag_relation'),(SELECT id FROM plugin_tag WHERE name='DevSecOps') , (SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),'now()', 1, 'now()', 1);
18+
19+
20+
INSERT INTO "plugin_stage_mapping" ("plugin_id","stage_type","created_on", "created_by", "updated_on", "updated_by")
21+
VALUES ((SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),3,'now()', 1, 'now()', 1);
22+
23+
INSERT INTO "plugin_pipeline_script" ("id", "script","type","deleted","created_on", "created_by", "updated_on", "updated_by")
24+
VALUES (
25+
nextval('id_seq_plugin_pipeline_script'),
26+
E'
27+
set -ex
28+
arch=$(uname -m)
29+
os=$(uname -s)
30+
echo $arch
31+
echo $os
32+
command=$(wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-$os-$arch)
33+
echo $command
34+
docker_path="Dockerfile"
35+
echo $docker_path
36+
if [ ! -z "$DockerFilePath" ]
37+
then
38+
docker_path=$DockerFilePath
39+
fi
40+
echo $docker_path
41+
cp hadolint-Linux-x86_64 hadolint
42+
chmod +x hadolint
43+
if [[ $FailOnError == "true" ]]
44+
then
45+
./hadolint "/devtroncd/$docker_path"
46+
else
47+
./hadolint "/devtroncd/$docker_path" --no-fail
48+
fi
49+
50+
',
51+
'SHELL',
52+
'f',
53+
'now()',
54+
1,
55+
'now()',
56+
1
57+
);
58+
59+
60+
61+
62+
63+
INSERT INTO "plugin_step" ("id", "plugin_id","name","description","index","step_type","script_id","deleted", "created_on", "created_by", "updated_on", "updated_by")
64+
VALUES (nextval('id_seq_plugin_step'),(SELECT id FROM plugin_metadata WHERE plugin_version='1.0.0' and name='Docker Lint' and deleted= false),'Step 1','Step 1 - Triggering Docker Lint','1','INLINE',(SELECT last_value FROM id_seq_plugin_pipeline_script),'f','now()', 1, 'now()', 1);
65+
66+
67+
INSERT INTO "plugin_step_variable" ("id", "plugin_step_id", "name", "format", "description", "is_exposed", "allow_empty_value", "variable_type", "value_type","default_value", "variable_step_index", "deleted", "created_on", "created_by", "updated_on", "updated_by")
68+
VALUES (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.plugin_version='1.0.0' and p.name='Docker Lint' and p.deleted=false and ps."index"=1 and ps.deleted=false), 'DockerFilePath','STRING','Specify the file path to the Dockerfile for linting. Default path is Dockerfile if not specified',true,true,'INPUT','NEW','',1 ,'f','now()', 1, 'now()', 1);
69+
70+
71+
INSERT INTO "plugin_step_variable" ("id", "plugin_step_id", "name", "format", "description", "is_exposed", "allow_empty_value","variable_type", "value_type","default_value", "variable_step_index", "deleted", "created_on", "created_by", "updated_on", "updated_by")
72+
VALUES (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.plugin_version='1.0.0' and p.name='Docker Lint' and p.deleted=false and ps."index"=1 and ps.deleted=false), 'FailOnError','STRING','Pass true/false to fail/pass the pipeline on error in docker lint',true,false,'INPUT','NEW','false',1 ,'f','now()', 1, 'now()', 1);
73+

0 commit comments

Comments
 (0)