From ccd5993ce1ec449c021b5707ac4d735dc52567e6 Mon Sep 17 00:00:00 2001
From: zmartins <zfilho@gitlab.com>
Date: Mon, 13 Apr 2020 18:31:02 -0600
Subject: [PATCH] Add WAF and Cilium Log column for Fluentd table

Fluentd cluster application table was previously
setting WAF path only
---
 ...af_and_cilium_flags_into_fluentd_table.yml |  5 ++++
 ...and_cilium_logs_to_applications_fluentd.rb | 29 +++++++++++++++++++
 db/structure.sql                              |  5 +++-
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 changelogs/unreleased/add_waf_and_cilium_flags_into_fluentd_table.yml
 create mode 100644 db/migrate/20200413230056_add_waf_and_cilium_logs_to_applications_fluentd.rb

diff --git a/changelogs/unreleased/add_waf_and_cilium_flags_into_fluentd_table.yml b/changelogs/unreleased/add_waf_and_cilium_flags_into_fluentd_table.yml
new file mode 100644
index 00000000000..8f652cc336a
--- /dev/null
+++ b/changelogs/unreleased/add_waf_and_cilium_flags_into_fluentd_table.yml
@@ -0,0 +1,5 @@
+---
+title: Add WAF and Cilium Log column for Fluentd table
+merge_request: 29457
+author:
+type: changed
diff --git a/db/migrate/20200413230056_add_waf_and_cilium_logs_to_applications_fluentd.rb b/db/migrate/20200413230056_add_waf_and_cilium_logs_to_applications_fluentd.rb
new file mode 100644
index 00000000000..46047b74f84
--- /dev/null
+++ b/db/migrate/20200413230056_add_waf_and_cilium_logs_to_applications_fluentd.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddWafAndCiliumLogsToApplicationsFluentd < ActiveRecord::Migration[6.0]
+  include Gitlab::Database::MigrationHelpers
+
+  DOWNTIME = false
+
+  disable_ddl_transaction!
+
+  def up
+    add_column_with_default(:clusters_applications_fluentd,
+                            :waf_log_enabled,
+                            :boolean,
+                            default: true,
+                            allow_null: false)
+    add_column_with_default(:clusters_applications_fluentd,
+                            :cilium_log_enabled,
+                            :boolean,
+                            default: true,
+                            allow_null: false)
+  end
+
+  def down
+    remove_column(:clusters_applications_fluentd,
+                  :waf_log_enabled)
+    remove_column(:clusters_applications_fluentd,
+                  :cilium_log_enabled)
+  end
+end
diff --git a/db/structure.sql b/db/structure.sql
index fba0fe94ea5..8899b789811 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -1663,7 +1663,9 @@ CREATE TABLE public.clusters_applications_fluentd (
     updated_at timestamp with time zone NOT NULL,
     version character varying(255) NOT NULL,
     host character varying(255) NOT NULL,
-    status_reason text
+    status_reason text,
+    waf_log_enabled boolean DEFAULT true NOT NULL,
+    cilium_log_enabled boolean DEFAULT true NOT NULL
 );
 
 CREATE SEQUENCE public.clusters_applications_fluentd_id_seq
@@ -13236,6 +13238,7 @@ COPY "schema_migrations" (version) FROM STDIN;
 20200409211607
 20200410232012
 20200413072059
+20200413230056
 20200414144547
 20200415160722
 20200415161021
-- 
2.30.9