Skip to content

Commit 5fbecfa

Browse files
committed
fix migration numbering. udpate CH schema file
1 parent 7d2dbda commit 5fbecfa

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

db/clickhouse/schema.sql

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,76 @@ JOIN (SELECT event_id, string_value as currency
281281
WHERE positionCaseInsensitive(data_key, 'currency') > 0) c
282282
ON c.event_id = ed.event_id
283283
WHERE positionCaseInsensitive(data_key, 'revenue') > 0;
284+
285+
-- Create Performance
286+
CREATE TABLE umami.website_performance
287+
(
288+
website_id UUID,
289+
session_id UUID,
290+
visit_id UUID,
291+
url_path String,
292+
lcp Nullable(Decimal(10, 1)),
293+
inp Nullable(Decimal(10, 1)),
294+
cls Nullable(Decimal(10, 4)),
295+
fcp Nullable(Decimal(10, 1)),
296+
ttfb Nullable(Decimal(10, 1)),
297+
created_at DateTime('UTC')
298+
)
299+
ENGINE = MergeTree
300+
PARTITION BY toYYYYMM(created_at)
301+
ORDER BY (website_id, toStartOfHour(created_at), session_id)
302+
SETTINGS index_granularity = 8192;
303+
304+
-- Performance hourly aggregation
305+
CREATE TABLE umami.website_performance_hourly
306+
(
307+
website_id UUID,
308+
url_path String,
309+
lcp_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 1))),
310+
lcp_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 1))),
311+
lcp_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 1))),
312+
inp_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 1))),
313+
inp_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 1))),
314+
inp_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 1))),
315+
cls_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 4))),
316+
cls_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 4))),
317+
cls_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 4))),
318+
fcp_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 1))),
319+
fcp_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 1))),
320+
fcp_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 1))),
321+
ttfb_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 1))),
322+
ttfb_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 1))),
323+
ttfb_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 1))),
324+
sample_count SimpleAggregateFunction(sum, UInt64),
325+
created_at DateTime('UTC')
326+
)
327+
ENGINE = AggregatingMergeTree
328+
PARTITION BY toYYYYMM(created_at)
329+
ORDER BY (website_id, toStartOfHour(created_at), url_path)
330+
SETTINGS index_granularity = 8192;
331+
332+
CREATE MATERIALIZED VIEW umami.website_performance_hourly_mv
333+
TO umami.website_performance_hourly
334+
AS
335+
SELECT
336+
website_id,
337+
url_path,
338+
quantileState(0.5)(lcp) as lcp_p50,
339+
quantileState(0.75)(lcp) as lcp_p75,
340+
quantileState(0.95)(lcp) as lcp_p95,
341+
quantileState(0.5)(inp) as inp_p50,
342+
quantileState(0.75)(inp) as inp_p75,
343+
quantileState(0.95)(inp) as inp_p95,
344+
quantileState(0.5)(cls) as cls_p50,
345+
quantileState(0.75)(cls) as cls_p75,
346+
quantileState(0.95)(cls) as cls_p95,
347+
quantileState(0.5)(fcp) as fcp_p50,
348+
quantileState(0.75)(fcp) as fcp_p75,
349+
quantileState(0.95)(fcp) as fcp_p95,
350+
quantileState(0.5)(ttfb) as ttfb_p50,
351+
quantileState(0.75)(ttfb) as ttfb_p75,
352+
quantileState(0.95)(ttfb) as ttfb_p95,
353+
count() as sample_count,
354+
toStartOfHour(created_at) as created_at
355+
FROM umami.website_performance
356+
GROUP BY website_id, url_path, toStartOfHour(created_at);

prisma/migrations/18_add_session_recording/migration.sql renamed to prisma/migrations/19_add_session_recording/migration.sql

File renamed without changes.

0 commit comments

Comments
 (0)