mirror of
https://github.com/kremalicious/umami.git
synced 2025-01-12 05:55:51 +01:00
create new mysql schema file
This commit is contained in:
parent
5f159ed5ce
commit
f10694d07e
@ -3,101 +3,114 @@ generator client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "mysql"
|
provider = "postgresql"
|
||||||
url = env("DATABASE_URL")
|
url = env("DATABASE_URL")
|
||||||
|
relationMode = "prisma"
|
||||||
}
|
}
|
||||||
|
|
||||||
model account {
|
model User {
|
||||||
id Int @id @default(autoincrement()) @map("user_id") @db.UnsignedInt
|
id String @id @unique @map("user_id") @db.Uuid
|
||||||
username String @unique() @db.VarChar(255)
|
username String @unique @db.VarChar(255)
|
||||||
password String @db.VarChar(60)
|
password String @db.VarChar(60)
|
||||||
isAdmin Boolean @default(false) @map("is_admin")
|
role String @map("role") @db.VarChar(50)
|
||||||
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||||
updatedAt DateTime? @default(now()) @map("updated_at") @db.Timestamp(0)
|
updatedAt DateTime? @map("updated_at") @db.Timestamptz(6)
|
||||||
accountUuid String @unique() @map("account_uuid") @db.VarChar(36)
|
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(6)
|
||||||
website website[]
|
|
||||||
|
|
||||||
@@index([accountUuid])
|
teamUser TeamUser[]
|
||||||
|
Website Website[]
|
||||||
|
|
||||||
|
@@map("user")
|
||||||
}
|
}
|
||||||
|
|
||||||
model event {
|
model Session {
|
||||||
id Int @id @default(autoincrement()) @map("event_id") @db.UnsignedInt
|
id String @id @unique @map("session_id") @db.Uuid
|
||||||
websiteId Int @map("website_id") @db.UnsignedInt
|
websiteId String @map("website_id") @db.Uuid
|
||||||
sessionId Int @map("session_id") @db.UnsignedInt
|
hostname String? @db.VarChar(100)
|
||||||
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
|
browser String? @db.VarChar(20)
|
||||||
url String @db.VarChar(500)
|
os String? @db.VarChar(20)
|
||||||
eventName String @map("event_name") @db.VarChar(50)
|
device String? @db.VarChar(20)
|
||||||
eventUuid String @unique() @map("event_uuid") @db.VarChar(36)
|
screen String? @db.VarChar(11)
|
||||||
session session @relation(fields: [sessionId], references: [id])
|
language String? @db.VarChar(35)
|
||||||
website website @relation(fields: [websiteId], references: [id])
|
country String? @db.Char(2)
|
||||||
eventData eventData?
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||||
|
|
||||||
@@index([createdAt])
|
@@index([createdAt])
|
||||||
@@index([sessionId])
|
|
||||||
@@index([websiteId])
|
@@index([websiteId])
|
||||||
@@index([eventUuid])
|
@@map("session")
|
||||||
}
|
}
|
||||||
|
|
||||||
model eventData {
|
model Website {
|
||||||
id Int @id @default(autoincrement()) @map("event_data_id") @db.UnsignedInt
|
id String @id @unique @map("website_id") @db.Uuid
|
||||||
eventId Int @unique @map("event_id") @db.UnsignedInt
|
name String @db.VarChar(100)
|
||||||
eventData Json @map("event_data")
|
domain String? @db.VarChar(500)
|
||||||
event event @relation(fields: [eventId], references: [id])
|
shareId String? @unique @map("share_id") @db.VarChar(50)
|
||||||
|
revId Int @default(0) @map("rev_id") @db.Integer
|
||||||
|
userId String? @map("user_id") @db.Uuid
|
||||||
|
teamId String? @map("team_id") @db.Uuid
|
||||||
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||||
|
updatedAt DateTime? @map("updated_at") @db.Timestamptz(6)
|
||||||
|
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(6)
|
||||||
|
|
||||||
@@map("event_data")
|
team Team? @relation(fields: [teamId], references: [id])
|
||||||
|
user User? @relation(fields: [userId], references: [id])
|
||||||
|
|
||||||
|
@@index([teamId])
|
||||||
|
@@index([userId])
|
||||||
|
@@index([createdAt])
|
||||||
|
@@index([shareId])
|
||||||
|
@@map("website")
|
||||||
}
|
}
|
||||||
|
|
||||||
model pageview {
|
model WebsiteEvent {
|
||||||
id Int @id @default(autoincrement()) @map("view_id") @db.UnsignedInt
|
id String @id() @map("event_id") @db.Uuid
|
||||||
websiteId Int @map("website_id") @db.UnsignedInt
|
websiteId String @map("website_id") @db.Uuid
|
||||||
sessionId Int @map("session_id") @db.UnsignedInt
|
sessionId String @map("session_id") @db.Uuid
|
||||||
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||||
url String @db.VarChar(500)
|
url String @db.VarChar(500)
|
||||||
referrer String? @db.VarChar(500)
|
referrer String? @db.VarChar(500)
|
||||||
session session @relation(fields: [sessionId], references: [id])
|
eventType Int @default(1) @map("event_type") @db.Integer
|
||||||
website website @relation(fields: [websiteId], references: [id])
|
eventName String? @map("event_name") @db.VarChar(50)
|
||||||
|
eventData Json? @map("event_data")
|
||||||
|
|
||||||
@@index([createdAt])
|
@@index([createdAt])
|
||||||
@@index([sessionId])
|
@@index([sessionId])
|
||||||
|
@@index([websiteId])
|
||||||
@@index([websiteId, createdAt])
|
@@index([websiteId, createdAt])
|
||||||
@@index([websiteId])
|
|
||||||
@@index([websiteId, sessionId, createdAt])
|
@@index([websiteId, sessionId, createdAt])
|
||||||
|
@@map("website_event")
|
||||||
}
|
}
|
||||||
|
|
||||||
model session {
|
model Team {
|
||||||
id Int @id @default(autoincrement()) @map("session_id") @db.UnsignedInt
|
id String @id() @unique() @map("team_id") @db.Uuid
|
||||||
sessionUuid String @unique() @map("session_uuid") @db.VarChar(36)
|
name String @db.VarChar(50)
|
||||||
websiteId Int @map("website_id") @db.UnsignedInt
|
userId String @map("user_id") @db.Uuid
|
||||||
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
|
accessCode String? @unique @map("access_code") @db.VarChar(50)
|
||||||
hostname String? @db.VarChar(100)
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||||
browser String? @db.VarChar(20)
|
updatedAt DateTime? @map("updated_at") @db.Timestamptz(6)
|
||||||
os String? @db.VarChar(20)
|
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(6)
|
||||||
device String? @db.VarChar(20)
|
|
||||||
screen String? @db.VarChar(11)
|
|
||||||
language String? @db.VarChar(35)
|
|
||||||
country String? @db.Char(2)
|
|
||||||
website website @relation(fields: [websiteId], references: [id])
|
|
||||||
event event[]
|
|
||||||
pageview pageview[]
|
|
||||||
|
|
||||||
@@index([createdAt])
|
teamUsers TeamUser[]
|
||||||
@@index([websiteId])
|
Website Website[]
|
||||||
@@index([sessionUuid])
|
|
||||||
}
|
|
||||||
|
|
||||||
model website {
|
|
||||||
id Int @id @default(autoincrement()) @map("website_id") @db.UnsignedInt
|
|
||||||
websiteUuid String @unique() @map("website_uuid") @db.VarChar(36)
|
|
||||||
userId Int @map("user_id") @db.UnsignedInt
|
|
||||||
name String @db.VarChar(100)
|
|
||||||
domain String? @db.VarChar(500)
|
|
||||||
shareId String? @unique() @map("share_id") @db.VarChar(64)
|
|
||||||
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
|
|
||||||
account account @relation(fields: [userId], references: [id])
|
|
||||||
event event[]
|
|
||||||
pageview pageview[]
|
|
||||||
session session[]
|
|
||||||
|
|
||||||
@@index([userId])
|
@@index([userId])
|
||||||
@@index([websiteUuid])
|
@@index([accessCode])
|
||||||
|
@@map("team")
|
||||||
|
}
|
||||||
|
|
||||||
|
model TeamUser {
|
||||||
|
id String @id() @unique() @map("team_user_id") @db.Uuid
|
||||||
|
teamId String @map("team_id") @db.Uuid
|
||||||
|
userId String @map("user_id") @db.Uuid
|
||||||
|
role String @map("role") @db.VarChar(50)
|
||||||
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||||
|
updatedAt DateTime? @map("updated_at") @db.Timestamptz(6)
|
||||||
|
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(6)
|
||||||
|
|
||||||
|
team Team @relation(fields: [teamId], references: [id])
|
||||||
|
user User @relation(fields: [userId], references: [id])
|
||||||
|
|
||||||
|
@@index([teamId])
|
||||||
|
@@index([userId])
|
||||||
|
@@map("team_user")
|
||||||
}
|
}
|
||||||
|
116
db/mysql/schema_old.prisma
Normal file
116
db/mysql/schema_old.prisma
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
}
|
||||||
|
|
||||||
|
datasource db {
|
||||||
|
provider = "mysql"
|
||||||
|
url = env("DATABASE_URL")
|
||||||
|
relationMode = "prisma"
|
||||||
|
}
|
||||||
|
|
||||||
|
model User {
|
||||||
|
id String @id @unique @map("user_id") @db.VarChar(36)
|
||||||
|
username String @unique @db.VarChar(255)
|
||||||
|
password String @db.VarChar(60)
|
||||||
|
role String @map("role") @db.VarChar(50)
|
||||||
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||||
|
updatedAt DateTime? @map("updated_at") @db.Timestamptz(0)
|
||||||
|
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(0)
|
||||||
|
|
||||||
|
teamUser TeamUser[]
|
||||||
|
Website Website[]
|
||||||
|
|
||||||
|
@@map("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)
|
||||||
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(0)
|
||||||
|
|
||||||
|
@@index([createdAt])
|
||||||
|
@@index([websiteId])
|
||||||
|
@@map("session")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Website {
|
||||||
|
id String @id @unique @map("website_id") @db.VarChar(36)
|
||||||
|
name String @db.VarChar(100)
|
||||||
|
domain String? @db.VarChar(500)
|
||||||
|
shareId String? @unique @map("share_id") @db.VarChar(50)
|
||||||
|
revId Int @default(0) @map("rev_id") @db.UnsignedInt
|
||||||
|
userId String? @map("user_id") @db.VarChar(36)
|
||||||
|
teamId String? @map("team_id") @db.VarChar(36)
|
||||||
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(0)
|
||||||
|
updatedAt DateTime? @map("updated_at") @db.Timestamptz(0)
|
||||||
|
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(0)
|
||||||
|
|
||||||
|
team Team? @relation(fields: [teamId], references: [id])
|
||||||
|
user User? @relation(fields: [userId], references: [id])
|
||||||
|
|
||||||
|
@@index([teamId])
|
||||||
|
@@index([userId])
|
||||||
|
@@index([createdAt])
|
||||||
|
@@index([shareId])
|
||||||
|
@@map("website")
|
||||||
|
}
|
||||||
|
|
||||||
|
model WebsiteEvent {
|
||||||
|
id String @id() @map("event_id") @db.VarChar(36)
|
||||||
|
websiteId String @map("website_id") @db.VarChar(36)
|
||||||
|
sessionId String @map("session_id") @db.VarChar(36)
|
||||||
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(0)
|
||||||
|
url String @db.VarChar(500)
|
||||||
|
referrer String? @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")
|
||||||
|
|
||||||
|
@@index([createdAt])
|
||||||
|
@@index([sessionId])
|
||||||
|
@@index([websiteId])
|
||||||
|
@@index([websiteId, createdAt])
|
||||||
|
@@index([websiteId, sessionId, createdAt])
|
||||||
|
@@map("website_event")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Team {
|
||||||
|
id String @id() @unique() @map("team_id") @db.VarChar(36)
|
||||||
|
name String @db.VarChar(50)
|
||||||
|
userId String @map("user_id") @db.VarChar(36)
|
||||||
|
accessCode String? @unique @map("access_code") @db.VarChar(50)
|
||||||
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(0)
|
||||||
|
updatedAt DateTime? @map("updated_at") @db.Timestamptz(0)
|
||||||
|
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(0)
|
||||||
|
|
||||||
|
teamUsers TeamUser[]
|
||||||
|
Website Website[]
|
||||||
|
|
||||||
|
@@index([userId])
|
||||||
|
@@index([accessCode])
|
||||||
|
@@map("team")
|
||||||
|
}
|
||||||
|
|
||||||
|
model TeamUser {
|
||||||
|
id String @id() @unique() @map("team_user_id") @db.VarChar(36)
|
||||||
|
teamId String @map("team_id") @db.VarChar(36)
|
||||||
|
userId String @map("user_id") @db.VarChar(36)
|
||||||
|
role String @map("role") @db.VarChar(50)
|
||||||
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(0)
|
||||||
|
updatedAt DateTime? @map("updated_at") @db.Timestamptz(0)
|
||||||
|
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(0)
|
||||||
|
|
||||||
|
team Team @relation(fields: [teamId], references: [id])
|
||||||
|
user User @relation(fields: [userId], references: [id])
|
||||||
|
|
||||||
|
@@index([teamId])
|
||||||
|
@@index([userId])
|
||||||
|
@@map("team_user")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user