diff --git a/ee/scripts/schema/db/init_dbs/clickhouse/1.22.0/1.22.0.sql b/ee/scripts/schema/db/init_dbs/clickhouse/1.22.0/1.22.0.sql index 995914e03..49b5c808f 100644 --- a/ee/scripts/schema/db/init_dbs/clickhouse/1.22.0/1.22.0.sql +++ b/ee/scripts/schema/db/init_dbs/clickhouse/1.22.0/1.22.0.sql @@ -151,8 +151,7 @@ CREATE TABLE IF NOT EXISTS product_analytics.events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) ORDER BY (project_id, "$event_name", created_at, session_id) - TTL _timestamp + INTERVAL 1 MONTH , - _deleted_at + INTERVAL 1 DAY DELETE WHERE _deleted_at != '1970-01-01 00:00:00'; + TTL _deleted_at + INTERVAL 1 DAY DELETE WHERE _deleted_at != '1970-01-01 00:00:00'; -- The list of events that should not be ingested, -- according to a specific event_name and optional properties diff --git a/ee/scripts/schema/db/init_dbs/clickhouse/create/init_schema.sql b/ee/scripts/schema/db/init_dbs/clickhouse/create/init_schema.sql index b3d156134..f2be335bf 100644 --- a/ee/scripts/schema/db/init_dbs/clickhouse/create/init_schema.sql +++ b/ee/scripts/schema/db/init_dbs/clickhouse/create/init_schema.sql @@ -9,8 +9,7 @@ CREATE TABLE IF NOT EXISTS experimental.autocomplete _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(_timestamp) - ORDER BY (project_id, type, value) - TTL _timestamp + INTERVAL 1 MONTH; + ORDER BY (project_id, type, value); CREATE TABLE IF NOT EXISTS experimental.events ( @@ -87,8 +86,7 @@ CREATE TABLE IF NOT EXISTS experimental.events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(datetime) - ORDER BY (project_id, datetime, event_type, session_id, message_id) - TTL datetime + INTERVAL 3 MONTH; + ORDER BY (project_id, datetime, event_type, session_id, message_id); @@ -140,7 +138,6 @@ CREATE TABLE IF NOT EXISTS experimental.sessions ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMMDD(datetime) ORDER BY (project_id, datetime, session_id) - TTL datetime + INTERVAL 3 MONTH SETTINGS index_granularity = 512; CREATE TABLE IF NOT EXISTS experimental.user_favorite_sessions @@ -152,8 +149,7 @@ CREATE TABLE IF NOT EXISTS experimental.user_favorite_sessions sign Int8 ) ENGINE = CollapsingMergeTree(sign) PARTITION BY toYYYYMM(_timestamp) - ORDER BY (project_id, user_id, session_id) - TTL _timestamp + INTERVAL 3 MONTH; + ORDER BY (project_id, user_id, session_id); CREATE TABLE IF NOT EXISTS experimental.user_viewed_sessions ( @@ -163,8 +159,7 @@ CREATE TABLE IF NOT EXISTS experimental.user_viewed_sessions _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(_timestamp) - ORDER BY (project_id, user_id, session_id) - TTL _timestamp + INTERVAL 3 MONTH; + ORDER BY (project_id, user_id, session_id); CREATE TABLE IF NOT EXISTS experimental.user_viewed_errors ( @@ -174,8 +169,7 @@ CREATE TABLE IF NOT EXISTS experimental.user_viewed_errors _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(_timestamp) - ORDER BY (project_id, user_id, error_id) - TTL _timestamp + INTERVAL 3 MONTH; + ORDER BY (project_id, user_id, error_id); CREATE TABLE IF NOT EXISTS experimental.issues ( @@ -188,8 +182,7 @@ CREATE TABLE IF NOT EXISTS experimental.issues _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(_timestamp) - ORDER BY (project_id, issue_id, type) - TTL _timestamp + INTERVAL 3 MONTH; + ORDER BY (project_id, issue_id, type); @@ -292,8 +285,7 @@ CREATE TABLE IF NOT EXISTS experimental.sessions_feature_flags _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(datetime) - ORDER BY (project_id, datetime, session_id, feature_flag_id, condition_id) - TTL datetime + INTERVAL 3 MONTH; + ORDER BY (project_id, datetime, session_id, feature_flag_id, condition_id); CREATE TABLE IF NOT EXISTS experimental.ios_events ( @@ -329,8 +321,7 @@ CREATE TABLE IF NOT EXISTS experimental.ios_events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(datetime) - ORDER BY (project_id, datetime, event_type, session_id, message_id) - TTL datetime + INTERVAL 3 MONTH; + ORDER BY (project_id, datetime, event_type, session_id, message_id); SET allow_experimental_json_type = 1; @@ -484,8 +475,7 @@ CREATE TABLE IF NOT EXISTS product_analytics.events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) ORDER BY (project_id, "$event_name", created_at, session_id) - TTL _timestamp + INTERVAL 1 MONTH , - _deleted_at + INTERVAL 1 DAY DELETE WHERE _deleted_at != '1970-01-01 00:00:00'; + TTL _deleted_at + INTERVAL 1 DAY DELETE WHERE _deleted_at != '1970-01-01 00:00:00'; -- The list of events that should not be ingested, -- according to a specific event_name and optional properties diff --git a/scripts/schema/db/init_dbs/clickhouse/1.22.0/1.22.0.sql b/scripts/schema/db/init_dbs/clickhouse/1.22.0/1.22.0.sql index 97eb1216d..279c9517e 100644 --- a/scripts/schema/db/init_dbs/clickhouse/1.22.0/1.22.0.sql +++ b/scripts/schema/db/init_dbs/clickhouse/1.22.0/1.22.0.sql @@ -9,8 +9,7 @@ CREATE TABLE IF NOT EXISTS experimental.autocomplete _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(_timestamp) - ORDER BY (project_id, type, value) - TTL _timestamp + INTERVAL 1 MONTH; + ORDER BY (project_id, type, value); CREATE TABLE IF NOT EXISTS experimental.events ( @@ -87,8 +86,7 @@ CREATE TABLE IF NOT EXISTS experimental.events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(datetime) - ORDER BY (project_id, datetime, event_type, session_id, message_id) - TTL datetime + INTERVAL 1 MONTH; + ORDER BY (project_id, datetime, event_type, session_id, message_id); @@ -140,7 +138,6 @@ CREATE TABLE IF NOT EXISTS experimental.sessions ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMMDD(datetime) ORDER BY (project_id, datetime, session_id) - TTL datetime + INTERVAL 1 MONTH SETTINGS index_granularity = 512; CREATE TABLE IF NOT EXISTS experimental.issues @@ -154,8 +151,7 @@ CREATE TABLE IF NOT EXISTS experimental.issues _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(_timestamp) - ORDER BY (project_id, issue_id, type) - TTL _timestamp + INTERVAL 1 MONTH; + ORDER BY (project_id, issue_id, type); CREATE TABLE IF NOT EXISTS experimental.ios_events ( @@ -191,8 +187,7 @@ CREATE TABLE IF NOT EXISTS experimental.ios_events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(datetime) - ORDER BY (project_id, datetime, event_type, session_id, message_id) - TTL datetime + INTERVAL 1 MONTH; + ORDER BY (project_id, datetime, event_type, session_id, message_id); SET allow_experimental_json_type = 1; @@ -345,8 +340,7 @@ CREATE TABLE IF NOT EXISTS product_analytics.events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) ORDER BY (project_id, "$event_name", created_at, session_id) - TTL _timestamp + INTERVAL 1 MONTH , - _deleted_at + INTERVAL 1 DAY DELETE WHERE _deleted_at != '1970-01-01 00:00:00'; + TTL _deleted_at + INTERVAL 1 DAY DELETE WHERE _deleted_at != '1970-01-01 00:00:00'; -- The list of events that should not be ingested, -- according to a specific event_name and optional properties diff --git a/scripts/schema/db/init_dbs/clickhouse/create/init_schema.sql b/scripts/schema/db/init_dbs/clickhouse/create/init_schema.sql index 150b7661e..f026be3b2 100644 --- a/scripts/schema/db/init_dbs/clickhouse/create/init_schema.sql +++ b/scripts/schema/db/init_dbs/clickhouse/create/init_schema.sql @@ -9,8 +9,7 @@ CREATE TABLE IF NOT EXISTS experimental.autocomplete _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(_timestamp) - ORDER BY (project_id, type, value) - TTL _timestamp + INTERVAL 1 MONTH; + ORDER BY (project_id, type, value); CREATE TABLE IF NOT EXISTS experimental.events ( @@ -87,8 +86,7 @@ CREATE TABLE IF NOT EXISTS experimental.events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(datetime) - ORDER BY (project_id, datetime, event_type, session_id, message_id) - TTL datetime + INTERVAL 1 MONTH; + ORDER BY (project_id, datetime, event_type, session_id, message_id); @@ -140,7 +138,6 @@ CREATE TABLE IF NOT EXISTS experimental.sessions ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMMDD(datetime) ORDER BY (project_id, datetime, session_id) - TTL datetime + INTERVAL 1 MONTH SETTINGS index_granularity = 512; CREATE TABLE IF NOT EXISTS experimental.issues @@ -154,8 +151,7 @@ CREATE TABLE IF NOT EXISTS experimental.issues _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(_timestamp) - ORDER BY (project_id, issue_id, type) - TTL _timestamp + INTERVAL 1 MONTH; + ORDER BY (project_id, issue_id, type); CREATE TABLE IF NOT EXISTS experimental.ios_events ( @@ -191,8 +187,7 @@ CREATE TABLE IF NOT EXISTS experimental.ios_events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) PARTITION BY toYYYYMM(datetime) - ORDER BY (project_id, datetime, event_type, session_id, message_id) - TTL datetime + INTERVAL 1 MONTH; + ORDER BY (project_id, datetime, event_type, session_id, message_id); SET allow_experimental_json_type = 1; @@ -346,8 +341,7 @@ CREATE TABLE IF NOT EXISTS product_analytics.events _timestamp DateTime DEFAULT now() ) ENGINE = ReplacingMergeTree(_timestamp) ORDER BY (project_id, "$event_name", created_at, session_id) - TTL _timestamp + INTERVAL 1 MONTH , - _deleted_at + INTERVAL 1 DAY DELETE WHERE _deleted_at != '1970-01-01 00:00:00'; + TTL _deleted_at + INTERVAL 1 DAY DELETE WHERE _deleted_at != '1970-01-01 00:00:00'; -- The list of events that should not be ingested, -- according to a specific event_name and optional properties