Init: RoggioApp Architecture, Prisma Schema, API MVP
This commit is contained in:
Executable
+199
@@ -0,0 +1,199 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = "postgresql://roggio:roggio_secret@192.168.20.252:5432/roggiodb"
|
||||
}
|
||||
|
||||
model Unit {
|
||||
id String @id @default(uuid())
|
||||
name String @db.VarChar(255)
|
||||
description String?
|
||||
parentId String?
|
||||
traits Json @default("{}")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
parent Unit? @relation("UnitHierarchy", fields: [parentId], references: [id])
|
||||
children Unit[] @relation("UnitHierarchy")
|
||||
}
|
||||
|
||||
model Person {
|
||||
id String @id @default(uuid())
|
||||
firstName String @db.VarChar(100)
|
||||
lastName String @db.VarChar(100)
|
||||
email String? @unique @db.VarChar(255)
|
||||
phone String? @db.VarChar(50)
|
||||
ssoId String? @unique @db.VarChar(255)
|
||||
traits Json @default("{}")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
groupMemberships GroupMembership[]
|
||||
}
|
||||
|
||||
model Group {
|
||||
id String @id @default(uuid())
|
||||
name String @db.VarChar(255)
|
||||
traits Json @default("{}")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
members GroupMembership[]
|
||||
}
|
||||
|
||||
model GroupMembership {
|
||||
id String @id @default(uuid())
|
||||
personId String
|
||||
groupId String
|
||||
role String @db.VarChar(50)
|
||||
group Group @relation(fields: [groupId], references: [id])
|
||||
person Person @relation(fields: [personId], references: [id])
|
||||
|
||||
@@unique([personId, groupId, role])
|
||||
}
|
||||
|
||||
model Event {
|
||||
id String @id @default(uuid())
|
||||
type String @db.VarChar(50)
|
||||
status String @db.VarChar(50)
|
||||
startTime DateTime
|
||||
endTime DateTime?
|
||||
targetUnitId String?
|
||||
targetGroupId String?
|
||||
targetPersonId String?
|
||||
payload Json @default("{}")
|
||||
parentEventId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model cities {
|
||||
id BigInt @id @default(autoincrement())
|
||||
name String @db.VarChar(255)
|
||||
state_id BigInt
|
||||
state_code String @db.VarChar(255)
|
||||
country_id BigInt
|
||||
country_code String @db.Char(2)
|
||||
type String? @db.VarChar(191)
|
||||
level Int?
|
||||
parent_id BigInt?
|
||||
latitude Decimal @db.Decimal(10, 8)
|
||||
longitude Decimal @db.Decimal(11, 8)
|
||||
native String? @db.VarChar(255)
|
||||
population BigInt?
|
||||
timezone String? @db.VarChar(255)
|
||||
translations String?
|
||||
created_at DateTime @default(dbgenerated("'2014-01-01 12:01:01'::timestamp without time zone")) @db.Timestamp(6)
|
||||
updated_at DateTime @default(now()) @db.Timestamp(6)
|
||||
flag Int @default(1) @db.SmallInt
|
||||
wikiDataId String? @db.VarChar(255)
|
||||
countries countries @relation(fields: [country_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
states states @relation(fields: [state_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@index([country_id])
|
||||
@@index([state_id])
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model countries {
|
||||
id BigInt @id @default(autoincrement())
|
||||
name String @db.VarChar(100)
|
||||
iso3 String? @db.Char(3)
|
||||
numeric_code String? @db.Char(3)
|
||||
iso2 String? @db.Char(2)
|
||||
phonecode String? @db.VarChar(255)
|
||||
capital String? @db.VarChar(255)
|
||||
currency String? @db.VarChar(255)
|
||||
currency_name String? @db.VarChar(255)
|
||||
currency_symbol String? @db.VarChar(255)
|
||||
tld String? @db.VarChar(255)
|
||||
native String? @db.VarChar(255)
|
||||
population BigInt?
|
||||
gdp BigInt?
|
||||
region String? @db.VarChar(255)
|
||||
region_id BigInt?
|
||||
subregion String? @db.VarChar(255)
|
||||
subregion_id BigInt?
|
||||
nationality String? @db.VarChar(255)
|
||||
area_sq_km Float?
|
||||
postal_code_format String? @db.VarChar(255)
|
||||
postal_code_regex String? @db.VarChar(255)
|
||||
timezones String?
|
||||
translations String?
|
||||
latitude Decimal? @db.Decimal(10, 8)
|
||||
longitude Decimal? @db.Decimal(11, 8)
|
||||
emoji String? @db.VarChar(191)
|
||||
emojiU String? @db.VarChar(191)
|
||||
created_at DateTime? @db.Timestamp(6)
|
||||
updated_at DateTime @default(now()) @db.Timestamp(6)
|
||||
flag Int @default(1) @db.SmallInt
|
||||
wikiDataId String? @db.VarChar(255)
|
||||
cities cities[]
|
||||
states states[]
|
||||
|
||||
@@index([region_id])
|
||||
@@index([subregion_id])
|
||||
}
|
||||
|
||||
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
|
||||
model states {
|
||||
id BigInt @id @default(autoincrement())
|
||||
name String @db.VarChar(255)
|
||||
country_id BigInt
|
||||
country_code String @db.Char(2)
|
||||
fips_code String? @db.VarChar(255)
|
||||
iso2 String? @db.VarChar(255)
|
||||
iso3166_2 String? @db.VarChar(10)
|
||||
type String? @db.VarChar(191)
|
||||
level Int?
|
||||
parent_id BigInt?
|
||||
native String? @db.VarChar(255)
|
||||
latitude Decimal? @db.Decimal(10, 8)
|
||||
longitude Decimal? @db.Decimal(11, 8)
|
||||
timezone String? @db.VarChar(255)
|
||||
translations String?
|
||||
created_at DateTime? @db.Timestamp(6)
|
||||
updated_at DateTime @default(now()) @db.Timestamp(6)
|
||||
flag Int @default(1) @db.SmallInt
|
||||
wikiDataId String? @db.VarChar(255)
|
||||
population String? @db.VarChar(255)
|
||||
cities cities[]
|
||||
countries countries @relation(fields: [country_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@index([country_id])
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// ADRESSEN (Shared Locations)
|
||||
// ============================================================================
|
||||
model Address {
|
||||
id String @id @default(uuid())
|
||||
street String @db.VarChar(255)
|
||||
streetNo String? @db.VarChar(50)
|
||||
postalCode String? @db.VarChar(50)
|
||||
|
||||
cityId Int?
|
||||
stateId Int?
|
||||
countryId Int?
|
||||
|
||||
rawCity String? @db.VarChar(255)
|
||||
rawCountry String? @db.VarChar(255)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// DER VAULT (Logisch getrennt - Später On-Premise)
|
||||
// ============================================================================
|
||||
model VaultData {
|
||||
id String @id @default(uuid())
|
||||
entityType String @db.VarChar(50)
|
||||
entityId String
|
||||
|
||||
// Die sensiblen Daten (sollten auf App-Ebene verschlüsselt werden)
|
||||
secureData String @db.Text
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
Reference in New Issue
Block a user