@startuml
frame AS_IS_ALL_SCHEME {
skinparam linetype ortho
scale 2500*1700

    entity "search_availability_flag_{guid_office}" as availability {
    * id : int auto_increment "PK"
    --
    *product : char(36)
    *is_availability : tinyint(1)
    *create_at : timestamp
    *update_at : timestamp
    --
    unique (product)
    }

    entity "search_remaining_{guid_office}" as remaining {
    * id: int auto_increment "PK"
    --
    *product: char(36)
    *remaining: int
    *create_at: timestamp
    *update_at: timestamp
    --
    unique (product)
    }

    entity "search_check" as search_check {
    *id: int auto_increment "PK"
    --
    *locality: char(36)
    *product: char(36)
    *update_at: timestamp
    --
    unique(locality, product)
    }
    entity "search_localities_offices" as localities_offices {
    *id: int auto_increment "PK"
    --
    *locality_guid: char(36)
    *office_guid: char(36)
    *is_active: tinyint(1)
    --
    unique (office_guid)
    }





    entity "search_countries" as countries {
    *id: int auto_increment "PK"
    --
    *code varchar(3)
    *name: varchar(256)
    *full_name: varchar(256)
    *alpha_2: varchar(2)
    *alpha_3: varchar(3)
    --
    unique (code)
    }
    entity "search_prices_types_localities" as prices_types_localities {
    *id: int auto_increment "PK"
    --
    *hash: char(40)
    *locality_guid: char(36)
    *price_type_guid: char(36)
    *type: varchar(128)
    --
    unique (hash)
    }

    entity "search_prices_types_products" as prices_types_products {
    *id: int auto_increment "PK"
    --
    *hash: char(40)
    *product_guid: char(36)
    *price_type_guid: char(36)
    *price: decimal(10, 2)
    *updated_at: timestamp
    --
    unique (hash)
    }

    entity "search_products_relevancy_counts" as products_relevancy_counts {
    *id: bigint: auto_increment "PK"
    --
    *product_guid: char(36)
    *orders: int(11)
    *views: int(11)
    *reviews: int(11)
    *updated_at: timestamp
    --
    unique (product_guid)
    }

    entity "search_products_relevancy_data_items" as relevancy_data_items {
    *id: bigint: auto_increment "PK"
    --
    *hash: char(40)
    *product_guid: char(36)
    *manufacter_guid: char(36)
    *seo_position: int
    *koef_sort: float
    *updated_at: timestamp
    --
    unique (hash)
    }

    entity "search_products_sort_rating" as products_sort_rating {
    *id: bigint: auto_increment "PK"
    --
    *product_guid: char(36)
    *rating: float
    *updated_at: timestamp
    --
    unique (product_guid)
    }

    entity "search_manufacturers_settings" as manufacturers_settings {
    *id: int auto_increment "PK"
    --
    *manufacturer_guid: char(36)
    *locality_guid: char(36)
    *is_hide: tinyint(1)
    *updated_at: timestamp
    *created_at: timestamp
    --
    unique (manufacturer_guid, locality_guid)
    }

    entity "search_manufacturers" as manufacturers {
    *id: int auto_increment "PK"
    --
    *guid: char(36)
    *name: varchar(256)
    *is_our: tinyint(1)
    *description: varchar(256)
    *updated_at: timestamp
    --
    unique (guid)
    }

    entity "search_products" as products {
    *id: int auto_increment "PK"
    --
    *is_consumable: tinyint(1)
    *is_on_site: tinyint(1)
    *is_visible: tinyint(1)
    *status: smallint
    *is_discountinued: tinyint(1)
    *is_for_order: tinyint(1)
    *sku: int
    *height: float
    *lenght: float
    *width: float
    *guid: char(36)
    *manufacter_guid: char(36)
    *name_site: varchar(256)
    *category: char(36)
    *name_pdm: varchar(256)
    *name_wtis: varchar(256)
    *name_contractor: varchar(256)
    *keywords: varchar(256)
    *lights: varchar(20)
    *country_code: varchar(3)
    *uri: text
    *advantages: text
    *description: text
    *equipment: text
    *features: text
    *updated_at: timestamp
    --
    unique (guid)
    }

    entity "search_products_categories" as products_categories {
    *id: int auto_increment "PK"
    --
    *hash: char(40)
    *product_guid: char(36)
    *category_guid: char(36)
    *is_enabled: tinyint(1)
    *updated_at: timestamp
    --
    unique (hash)
    }

    entity "search_categories_settings" as categories_settings {
    *id: int auto_increment "PK"
    --
    *category_guid: char(36)
    *locality_guid: char(36)
    *is_hide: tinyint(1)
    *updated_at: timestamp
    *created_at: timestamp
    --
    unique (category_guid, locality_guid)
    }

    entity "search_categories_relationship" as categories_relationship {
    *id: int auto_increment "PK"
    --
    *parent: char(36)
    *child: char(36)
    *main: tinyint(1)
    *level: int
    *line: int
    *created_at: timestamp
    }

    entity "search_categories" as categories {
    *id: int auto_increment "PK"
    --
    *guid: char(36)
    name: varchar(256)
    type: varchar(256)
    parent_guid: char(36)
    is_active: tinyint(1)
    is_enable: tinyint(1)
    up_caption: varchar(256)
    updated_at: timestamp
    --
    unique (guid)
    }

    entity "search_products_sale" as product_sale {
    *id: bigint: auto_increment "PK"
    --
    *hash: char(40)
    *guid: char(36)
    *product_guid: char(36)
    *locality_guid: char(36)
    remaining: int
    price: float
    updated_at: timestamp
    --
    unique (hash)
    }

    entity "search_promotions" as promotions {
    *id: int: auto_increment "PK"
    --
    *product_guid: char(36)
    *locality_guid char(36)
    *name: varchar(256)
    *updated_at: timestamp
    }

    entity "search_specifications_bool" as specifications_bool {
    *id: int auto_increment "PK"
    --
    *hash: char(40)
    *product_guid: char(36)
    *guid: char(36)
    *name: varchar(256)
    *unit: varchar(256)
    *description: text
    *value: tinyint(1)
    *updated_at: timestamp
    --
    unique (hash)
    }

    entity "search_specifications_collection" as specifications_collection {
    *id: int auto_increment "PK"
    --
    *hash: char(40)
    *product_guid: char(36)
    *guid: char(36)
    *name: varchar(256)
    *unit: varchar(256)
    *description: text
    *value: varchar(256)
    *value_guid: char(36)
    *updated_at: timestamp
    --
    unique (hash)
    }

    entity "search_specifications_float" as specifications_float {
    *id: int auto_increment "PK"
    --
    *hash: char(40)
    *product_guid: char(36)
    *guid: char(36)
    *name: varchar(256)
    *unit: varchar(256)
    *description: text
    *value: float
    *updated_at: timestamp
    --
    unique (hash)
    }

    entity "search_specifications_int" as specifications_int {
    *id: int auto_increment "PK"
    --
    *hash: char(40)
    *product_guid: char(36)
    *guid: char(36)
    *name: varchar(256)
    *unit: varchar(256)
    *description: text
    *value: int
    *updated_at: timestamp
    --
    unique (hash)
    }

    entity "search_specifications_range" as specifications_range {
    *id: int auto_increment "PK"
    --
    *hash: char(40)
    *product_guid: char(36)
    *guid: char(36)
    *name: varchar(256)
    *unit: varchar(256)
    *description: text
    *value_gte: float
    *value_lte: float
    *updated_at: timestamp
    --
    unique (hash)
    }

    entity "search_specifications_text" as specifications_text {
    *id: int auto_increment "PK"
    --
    *hash: char(40)
    *product_guid: char(36)
    *guid: char(36)
    *name: varchar(256)
    *unit: varchar(256)
    *description: text
    *value: varchar(256)
    *updated_at: timestamp
    --
    unique (hash)
    }
    entity "search_locality" as locality {
        *id: mediumint(9) auto_increment "PK"
        --
        *name: char(50)
        *english_name: varchar(255)
        *areg_id: char(36)
        *is_enabled: tinyint(1)
    }

    entity "search_dates_sync" as dates_sync {
        *id: int auto_increment "PK"
        --
        *is_successful tinyint(1)
        *'system': text
        *message: text
        *date: datetime
    }

    'Связи
    products -d----> specifications_bool
    specifications_bool -r-> specifications_range
    specifications_bool -r-> specifications_text
    specifications_bool -r-> specifications_collection
    specifications_bool -r-> specifications_int
    specifications_bool -r-> specifications_float
    'products -d---> specifications_range
    'products -d---> specifications_text
    'products -d---> specifications_collection
    'products -d---> specifications_int
    'products -d---> specifications_float

    note left of specifications_bool: Все таблицы с тх связаны с \nтаблицей товаров по product_guid
    products -l--> manufacturers
    manufacturers -l-> manufacturers_settings

    prices_types_localities -> localities_offices
    prices_types_products -> prices_types_localities

    products -d--> promotions
    products -d--> availability
    products -d--> search_check
    products --> remaining


    products -r--> relevancy_data_items
    product_sale -> localities_offices
    promotions -> localities_offices

    products -l--> prices_types_products

    products -u-> categories
    products -> products_relevancy_counts
    products -> product_sale
    products -> products_sort_rating


    categories -> categories_relationship
    categories -> categories_settings

    products_categories -> products
    products_categories -> categories

}
@enduml
