Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit ffc78c5

Browse files
committed
Setup analytics module and schema
1 parent 4381160 commit ffc78c5

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Add timescale
2+
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
3+
4+
-- CreateTable
5+
CREATE TABLE "event" (
6+
"id" UUID NOT NULL,
7+
"timestamp" TIMESTAMPTZ NOT NULL,
8+
"name" TEXT NOT NULL,
9+
"metadata" JSONB
10+
);
11+
12+
-- CreateIndex
13+
CREATE UNIQUE INDEX "event_id_key" ON "event"("id");
14+
15+
-- CreateIndex
16+
CREATE INDEX "event_name_time_idx" ON "event"("name", "timestamp" DESC);

Diff for: modules/analytics/db/migrations/migration_lock.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Please do not edit this file manually
2+
# It should be added in your version-control system (i.e. Git)
3+
provider = "postgresql"

Diff for: modules/analytics/db/schema.prisma

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
datasource db {
2+
provider = "postgresql"
3+
url = env("DATABASE_URL")
4+
5+
}
6+
7+
model Event {
8+
id String @db.Uuid @default(uuid()) @unique
9+
timestamp DateTime @db.Timestamptz
10+
name String
11+
metadata Json?
12+
13+
// in the init migration, we add the timescale extension and call create_hypertable().
14+
15+
@@index(fields: [name, timestamp(sort: Desc)], map: "event_name_time_idx")
16+
@@map("event")
17+
}

Diff for: modules/analytics/module.json

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
2-
"name": "Analytics",
3-
"description": "Track and visualize user behavior data. (Coming mid-2024)",
4-
"icon": "chart-line",
5-
"tags": [
6-
"game"
7-
],
8-
"authors": [],
9-
"status": "coming_soon",
10-
"scripts": {},
11-
"errors": {}
2+
"status": "stable",
3+
"name": "Analytics",
4+
"description": "Track and visualize user behavior data",
5+
"icon": "chart-line",
6+
"tags": [],
7+
"authors": [
8+
"rivet-gg",
9+
"ABCxFF"
10+
],
11+
"scripts": {
12+
},
13+
"errors": {},
14+
"dependencies": {}
1215
}

0 commit comments

Comments
 (0)