Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/click_house/migrate/main/20240115122100_drop_audit_events.rb')
-rw-r--r--db/click_house/migrate/main/20240115122100_drop_audit_events.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/db/click_house/migrate/main/20240115122100_drop_audit_events.rb b/db/click_house/migrate/main/20240115122100_drop_audit_events.rb
new file mode 100644
index 00000000000..198e83ff7ee
--- /dev/null
+++ b/db/click_house/migrate/main/20240115122100_drop_audit_events.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class DropAuditEvents < ClickHouse::Migration
+ def up
+ execute <<~SQL
+ DROP TABLE IF EXISTS audit_events;
+ SQL
+ end
+
+ def down
+ execute <<~SQL
+ CREATE TABLE IF NOT EXISTS audit_events
+ (
+ id UInt64 DEFAULT 0,
+ author_id UInt64 DEFAULT 0,
+ author_name String DEFAULT '',
+ created_at DateTime64(6, 'UTC') DEFAULT now(),
+ details String DEFAULT '',
+ entity_id UInt64 DEFAULT 0,
+ entity_path String DEFAULT '',
+ entity_type LowCardinality(String) DEFAULT '',
+ ip_address String DEFAULT '',
+ target_details String DEFAULT '',
+ target_id UInt64 DEFAULT 0,
+ target_type LowCardinality(String) DEFAULT '',
+ is_deleted UInt8 DEFAULT 0,
+ ) ENGINE = ReplacingMergeTree(created_at, is_deleted)
+ PARTITION BY toYear(created_at)
+ ORDER BY (entity_type, entity_id, author_id, created_at, id);
+ SQL
+
+ execute <<~SQL
+ ALTER TABLE audit_events
+ ADD PROJECTION IF NOT EXISTS by_id (SELECT * ORDER BY id);
+ SQL
+ end
+end