feat(dashboard): supporting schema, seed, catalog links, funnel/PM labels and API contract (merge resolution)

This commit is contained in:
fatemeh sane
2026-10-08 11:18:57 +03:30
parent b82c039265
commit 7bb432e715
13 changed files with 817 additions and 18 deletions
+22 -3
View File
@@ -165,13 +165,15 @@ CREATE TABLE category_attributes (
);
-- ---------- MATERIALS (GLOBAL catalog entities — v2.6/v2.7) ----------
-- Materials are global, category-free entities. name is GLOBALLY
-- unique (uq_material_name). topic is a legacy display column no longer
-- written by the app.
-- Materials are global entities. name is GLOBALLY unique (uq_material_name).
-- topic is a legacy display column; category_id (v2.8) is the dashboard's
-- Category→Material cascade link — backfilled from topic at API startup
-- (init_db.ensure_dashboard_schema; NULL = «بدون دسته»).
CREATE TABLE materials (
id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
name TEXT NOT NULL,
topic TEXT, -- LEGACY display column
category_id UUID REFERENCES material_categories(id) ON DELETE SET NULL,
canonical_unit_id INTEGER NOT NULL REFERENCES units(id) ON DELETE RESTRICT,
status material_status NOT NULL DEFAULT 'active',
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
@@ -481,6 +483,23 @@ CREATE INDEX idx_category_attrs_category ON category_attributes(category_id);
CREATE INDEX idx_category_attrs_attr_def ON category_attributes(attribute_definition_id);
CREATE INDEX idx_line_item_specs_attr_def ON line_item_specs(attribute_definition_id);
-- ============================================================================
-- MVP DASHBOARD INDEXES (v2.8 — aggregation queries in dashboard_service)
-- (Fresh installs; existing volumes get the same set idempotently via
-- init_db.ensure_dashboard_schema.)
-- ============================================================================
CREATE INDEX idx_materials_category ON materials(category_id);
CREATE INDEX idx_warehouses_project ON warehouses(project_id);
CREATE INDEX idx_inventory_tx_date ON inventory_transactions(transaction_date);
CREATE INDEX idx_inventory_tx_type_date ON inventory_transactions(transaction_type, transaction_date);
CREATE INDEX idx_quotes_accepted ON quotes(accepted_date) WHERE accepted_date IS NOT NULL;
CREATE INDEX idx_quotes_arrived ON quotes(arrived_date) WHERE arrived_date IS NOT NULL;
CREATE INDEX idx_quotes_status ON quotes(status);
CREATE INDEX idx_item_decisions_project ON item_decisions(project_id);
CREATE INDEX idx_item_receipts_received ON item_receipts(received_at);
CREATE INDEX idx_inventory_material_brand ON inventory(material_id, brand_id);
-- ============================================================================
-- QUOTE ATTACHMENTS (invoice / proforma files — bytes live in MinIO)
-- ============================================================================