Automatiska ID, nya registertyper och ID-register
- Löpande ID per bok och typ enligt idöversikten (KI, FI, BI, DI, LI, UI, FD, RI, RD, SI, REI, PI, SCI, KD-R_/KD-E_), prefix samlade i src/lib/ids.ts - Nya typer: Fordon, Skiss, Research, Referens, Appar, Hemsidor (grupp Register) - Sida med ID-register med sök och filter - Migration 0003_auto_ids med backfill av befintliga poster - ID visas i listor, postsidor, kartpanel och scheman - README och Register/-mallar Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0b65494cf5
commit
8a0e93f559
32 files changed
+664
-48
No files matched your search
+49
-22
@@ -17,6 +17,12 @@ enum EntityKind {
|
||||
SCENARIO
|
||||
EDUCATION
|
||||
PET
|
||||
VEHICLE
|
||||
RESEARCH
|
||||
REFERENCE
|
||||
SKETCH
|
||||
APP
|
||||
WEBSITE
|
||||
}
|
||||
|
||||
enum MapKind {
|
||||
@@ -50,12 +56,13 @@ model Book {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
|
||||
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
|
||||
entities Entity[]
|
||||
relations Relation[]
|
||||
shifts Shift[]
|
||||
maps BookMap[]
|
||||
templates Template[]
|
||||
counters IdCounter[]
|
||||
|
||||
@@index([ownerId])
|
||||
}
|
||||
@@ -69,27 +76,29 @@ model Entity {
|
||||
name String
|
||||
summary String? @db.Text
|
||||
imageFile String?
|
||||
// Skapas automatiskt, t.ex. KI-0001 (se src/lib/ids.ts)
|
||||
code String?
|
||||
tags String[]
|
||||
data Json @default("{}")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
book Book @relation(fields: [bookId], references: [id], onDelete: Cascade)
|
||||
outgoing Relation[] @relation("RelationFrom")
|
||||
incoming Relation[] @relation("RelationTo")
|
||||
shifts Shift[] @relation("ShiftPerson")
|
||||
hostedShifts Shift[] @relation("ShiftWorkplace")
|
||||
book Book @relation(fields: [bookId], references: [id], onDelete: Cascade)
|
||||
outgoing Relation[] @relation("RelationFrom")
|
||||
incoming Relation[] @relation("RelationTo")
|
||||
shifts Shift[] @relation("ShiftPerson")
|
||||
hostedShifts Shift[] @relation("ShiftWorkplace")
|
||||
markers Marker[]
|
||||
memberOf RelationMember[]
|
||||
|
||||
@@unique([bookId, code])
|
||||
@@index([bookId, kind])
|
||||
@@index([bookId, code])
|
||||
}
|
||||
|
||||
model Relation {
|
||||
id String @id @default(cuid())
|
||||
bookId String
|
||||
code String?
|
||||
fromId String
|
||||
toId String
|
||||
type String
|
||||
@@ -97,12 +106,13 @@ model Relation {
|
||||
data Json @default("{}")
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
book Book @relation(fields: [bookId], references: [id], onDelete: Cascade)
|
||||
from Entity @relation("RelationFrom", fields: [fromId], references: [id], onDelete: Cascade)
|
||||
to Entity @relation("RelationTo", fields: [toId], references: [id], onDelete: Cascade)
|
||||
book Book @relation(fields: [bookId], references: [id], onDelete: Cascade)
|
||||
from Entity @relation("RelationFrom", fields: [fromId], references: [id], onDelete: Cascade)
|
||||
to Entity @relation("RelationTo", fields: [toId], references: [id], onDelete: Cascade)
|
||||
// Fler deltagare utöver from/to, t.ex. i en vännergrupp
|
||||
members RelationMember[]
|
||||
|
||||
@@unique([bookId, code])
|
||||
@@index([bookId])
|
||||
@@index([fromId])
|
||||
@@index([toId])
|
||||
@@ -110,16 +120,18 @@ model Relation {
|
||||
|
||||
// Arbetspass. weekday: 0 = måndag ... 6 = söndag.
|
||||
model Shift {
|
||||
id String @id @default(cuid())
|
||||
bookId String
|
||||
personId String
|
||||
workplaceId String?
|
||||
weekday Int
|
||||
startTime String
|
||||
endTime String
|
||||
weeks WeekPattern @default(ALL)
|
||||
label String?
|
||||
createdAt DateTime @default(now())
|
||||
id String @id @default(cuid())
|
||||
bookId String
|
||||
personId String
|
||||
workplaceId String?
|
||||
weekday Int
|
||||
startTime String
|
||||
endTime String
|
||||
weeks WeekPattern @default(ALL)
|
||||
label String?
|
||||
// Schema-ID (SCI-0001), delas av en persons alla pass hos samma arbetsplats
|
||||
scheduleCode String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
book Book @relation(fields: [bookId], references: [id], onDelete: Cascade)
|
||||
person Entity @relation("ShiftPerson", fields: [personId], references: [id], onDelete: Cascade)
|
||||
@@ -133,6 +145,7 @@ model Shift {
|
||||
model BookMap {
|
||||
id String @id @default(cuid())
|
||||
bookId String
|
||||
code String?
|
||||
name String
|
||||
kind MapKind
|
||||
imageFile String?
|
||||
@@ -144,6 +157,7 @@ model BookMap {
|
||||
book Book @relation(fields: [bookId], references: [id], onDelete: Cascade)
|
||||
markers Marker[]
|
||||
|
||||
@@unique([bookId, code])
|
||||
@@index([bookId])
|
||||
}
|
||||
|
||||
@@ -151,6 +165,8 @@ model BookMap {
|
||||
model Marker {
|
||||
id String @id @default(cuid())
|
||||
mapId String
|
||||
// Placerings-ID, t.ex. PI-0001
|
||||
code String?
|
||||
entityId String?
|
||||
label String
|
||||
note String? @db.Text
|
||||
@@ -168,12 +184,12 @@ model Marker {
|
||||
|
||||
// Egen mall för en typ i en bok. Saknas raden används standardmallen.
|
||||
model Template {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
bookId String
|
||||
// EntityKind eller "RELATION"
|
||||
kind String
|
||||
fields Json
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
book Book @relation(fields: [bookId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@ -191,3 +207,14 @@ model RelationMember {
|
||||
@@unique([relationId, entityId])
|
||||
@@index([entityId])
|
||||
}
|
||||
|
||||
// Löpande nummer per bok och ID-typ, t.ex. key "KI" eller "KD-R"
|
||||
model IdCounter {
|
||||
bookId String
|
||||
key String
|
||||
next Int @default(0)
|
||||
|
||||
book Book @relation(fields: [bookId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([bookId, key])
|
||||
}
|
||||
Reference in new issue
Block a user