Files
duck-prod-manager/db_schema
bartool 32f126161e wersja 4 db schema
uproszczenie tabeli events
2026-04-22 22:16:11 +02:00

148 lines
3.0 KiB
Plaintext

// Use DBML to define your database structure
// Docs: https://dbml.dbdiagram.io/docs
Table models {
id int [pk]
name varchar [not null, unique]
strings int [not null, default: 6, note: "ilosc strun"]
scale int [not null, default: 645, note: "menzura w mm"]
}
Table colors {
id int [pk]
name varchar [not null, unique]
burst bool [not null, default: false, note: "czy ma cien"]
monolith bool [not null, default: false, note: "czy nie jest transparetny"]
}
Enum finish_type {
GLOSS
SATIN
MAT
NITRO
}
Enum part_type {
BODY
NECK
}
Table parts {
id int [pk]
product_id int [ref: > products.id, not null]
type part_type [not null]
color_top int [ref: > colors.id, not null]
color_back int [ref: > colors.id, not null]
finish_top finish_type [not null]
finish_back finish_type [not null]
indexes {
(product_id, type) [unique]
}
}
Table products {
id int [pk]
model int [ref: > models.id, not null]
note text
}
Table detail_products {
id int [pk]
product_id int [ref: - products.id, not null]
spec jsonb [note: "specyfikacja pobrana ze starego systemu w formie json"]
url varchar [note: "adres url strony ze specyfikacja ze starego systemu" ]
}
Table clients {
id int [pk]
name varchar [not null, note: "Nazwa klienta"]
country varchar [note: "Kraj klienta"]
}
Table orders {
id int [pk]
order_number int [not null, note: "XXXX, eg 0027"]
order_year int [not null, note: "YYYY, eg 2025"]
client_id int [ref: > clients.id ,not null]
indexes {
(order_number, order_year) [unique]
}
}
Table order_products {
id int [pk]
product_id int [ref: > products.id, not null, unique]
order_id int [ref: > orders.id, not null]
product_order_idx int [not null]
indexes {
(order_id, product_order_idx) [unique]
}
}
Table operations {
id int [pk]
operation varchar [not null, unique]
description text
}
Enum event_kind {
OPERATION
NOTE
}
Enum note_type {
INFO
ERROR
}
Table event_operations {
id int [pk]
event_id int [ref: - events.id, not null, unique]
operation_id int [ref: > operations.id, not null]
}
Table event_notes {
id int [pk]
event_id int [ref: - events.id, not null, unique]
type note_type [not null]
note text [not null]
}
Table event_photos {
id int [pk]
event_id int [ref: > events.id, not null]
photo_url varchar [not null]
description text
}
Table events {
id int [pk]
part_id int [ref: > parts.id, not null]
ordinal int [not null, note: "liczba porzadkowa, wielokrotnosc 32, zeby mozna bylo dodac pomiedzy"]
kind event_kind [not null, default: "OPERATION"]
date date [not null, note: "data jest ustawiana po wykonaniu operacji, niekonicznie w ten sam dzien. mozna edytowac"]
indexes {
(part_id, ordinal) [unique]
}
}
Table production_lists {
id int [pk]
name varchar [not null, unique]
description text
}
Table production_list_products {
id int [pk]
product_id int [ref: > products.id, not null]
prod_list_id int [ref: > production_lists.id, not null]
indexes {
(product_id, prod_list_id) [unique]
}
}