Skip to content
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
17 changes: 17 additions & 0 deletions scripts/sql/34704700_finops_tables.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2024. Devtron Inc.
*/

-- Drop indexes and constraints first
DROP INDEX IF EXISTS "public"."idx_cost_custom_view_name";
DROP INDEX IF EXISTS "public"."idx_cost_custom_view_name_cluster_unique";
DROP INDEX IF EXISTS "public"."idx_cost_custom_view_identifier_unique";

-- Drop table
DROP TABLE IF EXISTS "public"."cost_custom_view" CASCADE;

-- Drop sequences
DROP SEQUENCE IF EXISTS id_seq_cost_custom_view;

-- Drop column from cluster table
ALTER TABLE "public"."cluster" DROP COLUMN IF EXISTS "cost_module_enabled";
47 changes: 47 additions & 0 deletions scripts/sql/34704700_finops_tables.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2024. Devtron Inc.
*/

-- Create new cost_module_enabled column in cluster table
ALTER TABLE "public"."cluster" ADD COLUMN IF NOT EXISTS "cost_module_enabled" bool NOT NULL DEFAULT false;

-- Create sequence for cost_custom_view
CREATE SEQUENCE IF NOT EXISTS id_seq_cost_custom_view;

-- Create cost_custom_view table
CREATE TABLE IF NOT EXISTS "public"."cost_custom_view" (
"id" int4 NOT NULL DEFAULT nextval('id_seq_cost_custom_view'::regclass),
"name" varchar(255) NOT NULL,
"identifier" varchar(255) NOT NULL,
"description" text,
"filters" text NOT NULL,
"active" bool NOT NULL DEFAULT true,
"cluster_id" int4 NOT NULL,
"created_on" timestamptz DEFAULT NOW(),
"created_by" int4,
"updated_on" timestamptz,
"updated_by" int4,
PRIMARY KEY ("id")
);

-- Indexes for cost_custom_view
CREATE INDEX IF NOT EXISTS idx_cost_custom_view_name ON "public"."cost_custom_view"("name") WHERE "active" = true;

-- Unique constraints to ensure name uniqueness within cluster and identifier uniqueness globally
CREATE UNIQUE INDEX IF NOT EXISTS idx_cost_custom_view_name_cluster_unique
ON "public"."cost_custom_view"("name", "cluster_id")
WHERE "active" = true;

CREATE UNIQUE INDEX IF NOT EXISTS idx_cost_custom_view_identifier_unique
ON "public"."cost_custom_view"("identifier")
WHERE "active" = true;

-- Add comments for documentation
COMMENT ON TABLE "public"."cost_custom_view" IS 'User-defined custom views for cost analysis and filtering';
COMMENT ON COLUMN "public"."cost_custom_view"."filters" IS 'JSON string containing filter criteria for the custom view';

INSERT INTO "public"."chart_repo" ( "name", "url", "is_default", "active", "created_on", "created_by", "updated_on", "updated_by", "external","auth_mode","deleted","allow_insecure_connection")
SELECT 'opencost', 'https://opencost.github.io/opencost-helm-chart', 'f', 't', now(), 1, now(), 1, 't','ANONYMOUS','f','t'
WHERE NOT EXISTS (
SELECT 1 FROM "public"."chart_repo" WHERE "name" = 'opencost' and "active"=true and "deleted"=false

Check warning on line 46 in scripts/sql/34704700_finops_tables.up.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this comparison against the boolean literal.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_devtron&issues=AZr9gzo_Rwmy363ByoTH&open=AZr9gzo_Rwmy363ByoTH&pullRequest=6884

Check warning on line 46 in scripts/sql/34704700_finops_tables.up.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this comparison against the boolean literal.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_devtron&issues=AZr9gzo_Rwmy363ByoTG&open=AZr9gzo_Rwmy363ByoTG&pullRequest=6884
);
12 changes: 12 additions & 0 deletions scripts/sql/34804700_cost_module_installation.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2024. Devtron Inc.
*/

-- Remove cost module installation fields from cluster table
ALTER TABLE "public"."cluster" DROP COLUMN IF EXISTS "cost_module_installation_status";
ALTER TABLE "public"."cluster" DROP COLUMN IF EXISTS "cost_module_installation_error";
ALTER TABLE "public"."cluster" DROP COLUMN IF EXISTS "cost_config";


-- Drop default currency setting
DELETE FROM "public"."attributes" WHERE key = 'defaultCurrency';
26 changes: 26 additions & 0 deletions scripts/sql/34804700_cost_module_installation.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024. Devtron Inc.
*/

-- Add cost module installation status and configuration fields to cluster table
ALTER TABLE "public"."cluster" ADD COLUMN IF NOT EXISTS "cost_module_installation_status" varchar(50);
ALTER TABLE "public"."cluster" ADD COLUMN IF NOT EXISTS "cost_module_installation_error" text;

ALTER TABLE "public"."cluster" ADD COLUMN IF NOT EXISTS "gpu_installation_status" varchar(50);
ALTER TABLE "public"."cluster" ADD COLUMN IF NOT EXISTS "gpu_installation_error" text;

ALTER TABLE "public"."cluster" ADD COLUMN IF NOT EXISTS "cost_config" jsonb;

-- Add default currency setting (only if it doesn't already exist)
INSERT INTO "public"."attributes"(key, value, active, created_on, created_by, updated_on, updated_by)
SELECT 'defaultCurrency', 'USD', 't', NOW(), 1, NOW(), 1
WHERE NOT EXISTS (
SELECT 1 FROM "public"."attributes"
WHERE key = 'defaultCurrency'
);

INSERT INTO "public"."chart_repo" ( "name", "url", "is_default", "active", "created_on", "created_by", "updated_on", "updated_by", "external","auth_mode","deleted","allow_insecure_connection")
SELECT 'gpu-helm-charts', 'https://nvidia.github.io/dcgm-exporter/helm-charts', 'f', 't', now(), 1, now(), 1, 't','ANONYMOUS','f','t'
WHERE NOT EXISTS (
SELECT 1 FROM "public"."chart_repo" WHERE "name" = 'gpu-helm-charts' and "active"=true and "deleted"=false

Check warning on line 25 in scripts/sql/34804700_cost_module_installation.up.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this comparison against the boolean literal.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_devtron&issues=AZr9gzpJRwmy363ByoTI&open=AZr9gzpJRwmy363ByoTI&pullRequest=6884

Check warning on line 25 in scripts/sql/34804700_cost_module_installation.up.sql

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this comparison against the boolean literal.

See more on https://sonarcloud.io/project/issues?id=devtron-labs_devtron&issues=AZr9gzpJRwmy363ByoTJ&open=AZr9gzpJRwmy363ByoTJ&pullRequest=6884
);
72 changes: 72 additions & 0 deletions scripts/sql/34904700_athena_service.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
*
* * Copyright (c) 2020-2024. Devtron Inc.
*
*/

-- revision: 1_initial_db_schema_up.sql
-- description: Initial database schema creation
-- created: 2025-10-25 12:00:00

DROP TABLE public.checkpoint_blobs CASCADE;

DROP TABLE public.checkpoint_migrations CASCADE;

DROP TABLE public.checkpoint_writes CASCADE;

DROP TABLE public.checkpoints CASCADE;



DROP TABLE public.chat_graph_data CASCADE;

DROP TABLE public.chat_message_parts CASCADE;

DROP TABLE public.chat_messages CASCADE;

DROP TABLE public.chat_threads CASCADE;

DROP TABLE public.master_audit_logs CASCADE;

DROP TABLE public.recommendation_feeds CASCADE;

DROP TABLE public.runbook CASCADE;

DROP TABLE public.runbook_approval_status CASCADE;

DROP TABLE public.user_recommendation_feed_interactions CASCADE;

DROP TABLE public.wrk_eng_activity_trail CASCADE;

DROP TABLE public.wrk_eng_resource_discovery CASCADE;

DROP TABLE public.wrk_eng_resource_recommendation_bucket CASCADE;

DROP TABLE public.wrk_eng_runbook_transition_log CASCADE;

DROP TABLE public.wrk_eng_thought_process CASCADE;



DROP TYPE public.approvalstatus;

DROP TYPE public.messagestatusenum;

DROP TYPE public.recipienttypeenum;

DROP TYPE public.recommendationfeedpriority;

DROP TYPE public.recommendationfeedstatus;

DROP TYPE public.runbookstatus;

DROP TYPE public.sendertypeenum;

DROP TYPE public.threadstatusenum;

DROP TYPE public.userrecommendationfeedinteractionstatus;

DROP TYPE public.windowtype;

DROP TYPE public.windowunit;

Loading