diff --git a/db_schema b/db_schema index 3134bcf..912f9e1 100644 --- a/db_schema +++ b/db_schema @@ -88,35 +88,46 @@ Table operations { description text } -Enum event_type { +Enum event_kind { OPERATION + NOTE +} + +Enum note_type { INFO ERROR } -Table event_info { +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] - comment text [default: null] - photo_url varchar [default: null] - + photo_url varchar [not null] + description text } + Table events { id int [pk] part_id int [ref: > parts.id, not null] - operation_id int [ref: > operations.id] ordinal int [not null, note: "liczba porzadkowa, wielokrotnosc 32, zeby mozna bylo dodac pomiedzy"] - type event_type [not null, default: "OPERATION"] + 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] } - - checks { - `type != 'OPERATION' OR operation_id IS NOT NULL` [name: 'chk_event_operation_required'] - `type = 'OPERATION' OR operation_id IS NULL` [name: 'chk_event_operation_forbidden'] - } } Table production_lists { @@ -133,4 +144,4 @@ Table production_list_products { indexes { (product_id, prod_list_id) [unique] } -} \ No newline at end of file +}