From 2acdb09bfa98b5abf13b1042448dbcba44fd4b70 Mon Sep 17 00:00:00 2001 From: bartool Date: Wed, 22 Apr 2026 22:34:40 +0200 Subject: [PATCH] wersja 5 db schema dodalem wersjonowanie specyfikacji --- db_schema | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/db_schema b/db_schema index 912f9e1..824ff44 100644 --- a/db_schema +++ b/db_schema @@ -48,11 +48,27 @@ Table products { } 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" ] + product_id int [pk, ref: - products.id, not null] + spec jsonb [not null, note: "aktualny snapshot specyfikacji pobranej ze starego systemu"] + source_url varchar [note: "adres url strony ze specyfikacja ze starego systemu"] + source_hash varchar [not null, note: "hash aktualnego jsona specyfikacji do wykrywania zmian"] + last_fetched_at timestamp [not null, note: "czas ostatniego pobrania specyfikacji ze starego systemu"] + initial_spec_diff jsonb [note: "roznice miedzy aktualna specyfikacja a pierwsza pobrana wersja; null gdy brak zmian lub istnieje tylko pierwsza wersja"] +} +Table detail_product_versions { + id int [pk] + product_id int [ref: > products.id, not null] + version_no int [not null, note: "kolejny numer wersji specyfikacji dla danego produktu; 1 oznacza pierwsza pobrana wersje"] + spec jsonb [not null, note: "archiwalny snapshot specyfikacji ze starego systemu"] + source_hash varchar [not null, note: "hash archiwalnej wersji jsona"] + fetched_at timestamp [not null, note: "czas pobrania tej wersji"] + + indexes { + (product_id, fetched_at) + (product_id, version_no) [unique] + (product_id, source_hash) [unique] + } } Table clients {