update CH, postgres, MySQL schemas

This commit is contained in:
Francis Cao 2023-02-15 09:40:49 -08:00
parent 4351ef37f8
commit b6cc6cb655
5 changed files with 50 additions and 23 deletions

View File

@ -15,9 +15,12 @@ CREATE TABLE event
screen LowCardinality(String),
language LowCardinality(String),
country LowCardinality(String),
subdivision LowCardinality(String),
city String,
--pageview
url String,
referrer String,
page_title String,
--event
event_type UInt32,
event_name String,
@ -33,8 +36,7 @@ CREATE TABLE event_queue (
session_id UUID,
event_id Nullable(UUID),
rev_id UInt32,
url String,
referrer String,
--session
hostname LowCardinality(String),
browser LowCardinality(String),
os LowCardinality(String),
@ -42,6 +44,13 @@ CREATE TABLE event_queue (
screen LowCardinality(String),
language LowCardinality(String),
country LowCardinality(String),
subdivision LowCardinality(String),
city String,
--pageview
url String,
referrer String,
page_title String,
--event
event_type UInt32,
event_name String,
event_data String,
@ -60,8 +69,6 @@ SELECT website_id,
session_id,
event_id,
rev_id,
url,
referrer,
hostname,
browser,
os,
@ -69,6 +76,11 @@ SELECT website_id,
screen,
language,
country,
subdivision,
city,
url,
referrer,
page_title,
event_type,
event_name,
if((empty(event_data) = 0) AND startsWith(event_data, '"'), concat('{', event_data, ': true}'), event_data) AS event_data,

View File

@ -24,6 +24,8 @@ CREATE TABLE `session` (
`screen` VARCHAR(11) NULL,
`language` VARCHAR(35) NULL,
`country` CHAR(2) NULL,
`subdivision` CHAR(3) NULL,
`city` VARCHAR(50) NULL,
`created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
UNIQUE INDEX `session_session_id_key`(`session_id`),
@ -60,6 +62,7 @@ CREATE TABLE `website_event` (
`created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
`url` VARCHAR(500) NOT NULL,
`referrer` VARCHAR(500) NULL,
`page_title` VARCHAR(500) NULL,
`event_type` INTEGER UNSIGNED NOT NULL DEFAULT 1,
`event_name` VARCHAR(50) NULL,
`event_data` JSON NULL,

View File

@ -25,15 +25,17 @@ model User {
}
model Session {
id String @id @unique @map("session_id") @db.VarChar(36)
websiteId String @map("website_id") @db.VarChar(36)
hostname String? @db.VarChar(100)
browser String? @db.VarChar(20)
os String? @db.VarChar(20)
device String? @db.VarChar(20)
screen String? @db.VarChar(11)
language String? @db.VarChar(35)
country String? @db.Char(2)
id String @id @unique @map("session_id") @db.VarChar(36)
websiteId String @map("website_id") @db.VarChar(36)
hostname String? @db.VarChar(100)
browser String? @db.VarChar(20)
os String? @db.VarChar(20)
device String? @db.VarChar(20)
screen String? @db.VarChar(11)
language String? @db.VarChar(35)
country String? @db.Char(2)
subdivision String? @db.Char(3)
city String? @db.VarChar(50)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
@@index([createdAt])
@ -68,6 +70,7 @@ model WebsiteEvent {
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
url String @db.VarChar(500)
referrer String? @db.VarChar(500)
pageTitle String? @map("page_title") @db.VarChar(500)
eventType Int @default(1) @map("event_type") @db.UnsignedInt
eventName String? @map("event_name") @db.VarChar(50)
eventData Json? @map("event_data")

View File

@ -0,0 +1,6 @@
-- AlterTable
ALTER TABLE "session" ADD COLUMN "city" VARCHAR(50),
ADD COLUMN "subdivision" CHAR(3);
-- AlterTable
ALTER TABLE "website_event" ADD COLUMN "page_title" VARCHAR(500);

View File

@ -25,16 +25,18 @@ model User {
}
model Session {
id String @id @unique @map("session_id") @db.Uuid
websiteId String @map("website_id") @db.Uuid
hostname String? @db.VarChar(100)
browser String? @db.VarChar(20)
os String? @db.VarChar(20)
device String? @db.VarChar(20)
screen String? @db.VarChar(11)
language String? @db.VarChar(35)
country String? @db.Char(2)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
id String @id @unique @map("session_id") @db.Uuid
websiteId String @map("website_id") @db.Uuid
hostname String? @db.VarChar(100)
browser String? @db.VarChar(20)
os String? @db.VarChar(20)
device String? @db.VarChar(20)
screen String? @db.VarChar(11)
language String? @db.VarChar(35)
country String? @db.Char(2)
subdivision String? @db.Char(3)
city String? @db.VarChar(50)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
@@index([createdAt])
@@index([websiteId])
@ -68,6 +70,7 @@ model WebsiteEvent {
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
url String @db.VarChar(500)
referrer String? @db.VarChar(500)
pageTitle String? @map("page_title") @db.VarChar(500)
eventType Int @default(1) @map("event_type") @db.Integer
eventName String? @map("event_name") @db.VarChar(50)
eventData Json? @map("event_data")