NotificationEmails:
  actAs:
    Timestampable: ~
  columns:
    email:
      type: string(255)
    is_active:
      type: boolean
      default: 1
    notic_type:
      type: enum
      values: [call, order, exchange, all]

Tag:
  actAs:
    Timestampable: ~
    I18n:
      fields: [title]
  columns:
    title:
      type: string(255)
      notnull: true
  relations:
    Articles:
      onDelete: CASCADE
      class: Article
      local: tag_id
      foreign: article_id
      refClass: ArticleTags
    Videos:
      onDelete: CASCADE
      class: Video
      local: tag_id
      foreign: video_id
      refClass: VideoTags
    Products:
      onDelete: CASCADE
      class: Product
      local: tag_id
      foreign: product_id
      refClass: ProductTags
    Reviews:
      onDelete: CASCADE
      class: Review
      local: tag_id
      foreign: review_id
      refClass: ReviewTags

Video:
  actAs:
    Timestampable: ~
    I18n:
      fields: [title, available]
  columns:
    title:
      type: string(512)
      notnull: true
    vid:
      type: string(255)
      notnull: true
    cover:
      type: string(255)
      notnull: true
    available:
      type: boolean
      default: 0
  relations:
    Tags:
      onDelete: CASCADE
      class: Tag
      local: video_id
      foreign: tag_id
      refClass: VideoTags

VideoTags:
  columns:
    video_id:
      type: integer
      primary: true
    tag_id:
      type: integer
      primary: true
  relations:
    Video:
      onDelete: CASCADE
      local: video_id
      foreign: id
    Tag:
      onDelete: CASCADE
      local: tag_id
      foreign: id

Article:
  actAs:
    Timestampable: ~
    I18n:
      fields: [title, description, body, available]
  columns:
    alias:
      type: string(255)
      notnull: true
      unique: true
    title:
      type: string(512)
      notnull: true
    cover:
      type: string(255)
      notnull: true
    description:
      type: text
      notnull: true
    body:
      type: text
      notnull: true
    available:
      type: boolean
      default: 0
  relations:
    Tags:
      onDelete: CASCADE
      class: Tag
      local: article_id
      foreign: tag_id
      refClass: ArticleTags

ArticleTags:
  columns:
    article_id:
      type: integer
      primary: true
    tag_id:
      type: integer
      primary: true
  relations:
    Article:
      onDelete: CASCADE
      local: article_id
      foreign: id
    Tag:
      onDelete: CASCADE
      local: tag_id
      foreign: id

Review:
  actAs:
    Timestampable: ~
  columns:
    name:
      type: string(255)
      notnull: true
    phone:
      type: string(255)
      notnull: true
    body:
      type: text
    file:
      type: string(255)
    lang:
      type: string(2)
    is_activated:
      type: boolean
      notnull: true
      default: false
  relations:
    Tags:
      class: Tag
      onDelete: CASCADE
      local: review_id
      foreign: tag_id
      refClass: ReviewTags

ReviewTags:
  columns:
    review_id:
      type: integer
      primary: true
    tag_id:
      type: integer
      primary: true
  relations:
    Review:
      onDelete: CASCADE
      local: review_id
      foreign: id
    Tag:
      onDelete: CASCADE
      local: tag_id
      foreign: id

Page:
  actAs:
    Timestampable: ~
    I18n:
      fields: [title, body]
  columns:
    alias:
      type: string(255)
      notnull: true
      unique: true
    title:
      type: string(255)
      notnull: true
    body:
      type: text

Cat:
  actAs:
    Timestampable: ~
    I18n:
      fields: [title]
  columns:
    inner_id:
      type: text
    alias:
      type: string(255)
      notnull: true
      unique: true
    photo:
      type: string(255)
      notnull: true
    title:
      type: string(1000)
      notnull: true
    parent_id:
      type: integer
    order_id:
      type: integer
      notnull: true
      default: 100
    view_type:
      type: enum
      values: [Simple, Standart, BigStandart]
    is_filter:
      type: boolean
      notnull: true
      default: false
    is_main:
      type: boolean
      notnull: true
      default: false
    sort:
      type: integer
      default: 0
  relations:
    Parent:
      onDelete: CASCADE
      class: Cat
      local: parent_id
      foreign: id
      type: one
    Children:
      class: Cat
      local: id
      foreign: parent_id
      type: many
    Products:
      onDelete: CASCADE
      class: Product
      local: cat_id
      foreign: product_id
      refClass: CatProduct

CatParent:
  columns:
    cat_id:
      type: integer
      primary: true
    parent_id:
      type: integer
      primary: true
    order_id:
      type: integer
      notnull: true
      default: 0

CatProduct:
  columns:
    cat_id:
      type: integer
      primary: true
    product_id:
      type: integer
      primary: true
  relations:
    Cat:
      onDelete: CASCADE
      local: cat_id
      foreign: id
    Product:
      onDelete: CASCADE
      local: product_id
      foreign: id

Product:
  actAs:
    Timestampable: ~
    I18n:
      fields: [title, description, chemical_composition]
  columns:
    inner_id:
      type: text
    alias:
      type: string(255)
      notnull: true
      unique: true
    title:
      type: string(1000)
      notnull: true
    description:
      type: text
    chemical_composition:
      type: text
    product_img:
      type: text
    supplier_id:
      type: integer
    supplier_price:
      type: integer
    certificate:
      type: string(255)
    offer_count:
      type: integer
      default: 0
      notnull: true
    is_detail:
      type: boolean
      notnull: true
      default: true
    is_delete:
      type: boolean
      notnull: true
      default: false
    is_main:
      type: boolean
      notnull: true
      default: false
    show_main:
      type: boolean
      notnull: true
      default: false
    sort:
      type: integer
      default: 0
    free_shipping:
      type: boolean
      default: false
    the_weight:
      type: integer
      default: 10
  relations:
    Prop:
      class: ProductProp
      refClass: ProductPropValue
      local: id
      foreign: product_id
    Cats:
      class: Cat
      local: product_id
      foreign: cat_id
      refClass: CatProduct
    Suppliers:
      onDelete: CASCADE
      local: supplier_id
      foreign: id
    Tags:
      onDelete: CASCADE
      class: Tag
      local: product_id
      foreign: tag_id
      refClass: ProductTags

ProductTags:
  columns:
    product_id:
      type: integer
      primary: true
    tag_id:
      type: integer
      primary: true
  relations:
    Product:
      onDelete: CASCADE
      local: product_id
      foreign: id
    Tag:
      onDelete: CASCADE
      local: tag_id
      foreign: id

ProductProp:
  actAs:
    Timestampable: ~
    I18n:
      fields: [title]
  columns:
    inner_id:
      type: text
    title:
      type: string(255)
      notnull: true
    isList:
      type: boolean
      default: 0

ProductPropList:
  actAs:
    Timestampable: ~
    I18n:
      fields: [variant]
  columns:
    inner_id:
      type: text
    product_prop_id:
      type: integer
      notnull: true
    variant:
      type: string(255)
      notnull: true
  relations:
    ProductProp:
      onDelete: CASCADE
      local: product_prop_id
      foreign: id

ProductPropValue:
  actAs:
    Timestampable: ~
  columns:
    product_id:
      type: integer
      notnull: true
    prop_id:
      type: integer
      notnull: true
    value:
      type: decimal
      notnull: true
  relations:
    Product:
      onDelete: CASCADE
      local: product_id
      foreign: id
    ProductProp:
      onDelete: CASCADE
      local: prop_id
      foreign: id

Offer:
  actAs:
    Timestampable: ~
    I18n:
      fields: [title, quantity_type]
  columns:
    inner_id:
      type: text
    title:
      type: string(255)
      notnull: true
    quantity_type:
      type: string(255)
      notnull: true
    quantity_type_select:
      type: enum
      values: [m2, sheet, piece]
    price:
      type: integer
      notnull: true
    product_id:
      type: integer
      notnull: true
    img:
      type: text
    is_delete:
      type: boolean
      notnull: true
      default: false
    is_wholesale:
      type: boolean
      notnull: true
      default: false
    sort:
      type: integer
      default: 0
    discount_available:
      type: boolean
      default: false
  relations:
    Product:
      onDelete: CASCADE
      local: product_id
      foreign: id

Basket:
  actAs:
    Timestampable: ~
  columns:
    basket_order_id:
      type: integer
  relations:
    BasketOrder:
      onDelete: CASCADE
      local: basket_order_id
      foreign: id

BasketOrder:
  actAs:
    Timestampable: ~
  columns:
    username:
      type: string(255)
      notnull: true
    phone:
      type: string(24)
      notnull: true
    email:
      type: string(64)
    delivery_price:
      type: decimal
    delivery_type:
      type: enum
      values: [Самовывоз, Доставка по адресу]
      default: Самовывоз
      notnull: true
    delivery_address:
      type: string(255)
    comment:
      type: string(1000)
    payment_type:
      type: enum
      values: [Наличный, Безналичный]
      default: Наличный
      notnull: true
    is_confirm:
      type: boolean
      notnull: true
      default: false
    is_confirm_admin:
      type: boolean
      notnull: true
      default: false
    is_payed:
      type: boolean
      notnull: true
      default: false
    is_given:
      type: boolean
      notnull: true
      default: false
  relations:
    DiscountPhone:
      onDelete: SET NULL
      local: id
      foreign: order_id

BasketOffer:
  columns:
    amount:
      type: integer
      default: 1
      notnull: true
    basket_id:
      type: integer
      notnull: true
    offer_id:
      type: integer
      notnull: true
    price:
      type: decimal
      notnull: true
  relations:
    Offer:
      onDelete: CASCADE
      local: offer_id
      foreign: id
    Basket:
      onDelete: CASCADE
      local: basket_id
      foreign: id

Partners:
  actAs:
    Timestampable: ~
  columns:
    title:
      type: string(255)
      notnull: true
    cover:
      type: string(255)
      notnull: true
    link:
      type: text
    order_id:
      type: integer
      notnull: true
      default: 100

Suppliers:
  actAs:
    Timestampable: ~
  columns:
    org:
      type: text
      notnull: true
    fio:
      type: string(255)
    email:
      type: string(255)
    phone:
      type: string(255)

Callback:
  actAs:
    Timestampable: ~
  columns:
    name:
      type: string(255)
      notnull: true
    phone:
      type: string(255)
      notnull: true
    is_done:
      type: boolean
      notnull: true
      default: false
    offer_id:
      type: text
      notnull: false

Discount:
  actAs:
    Timestampable: ~
  columns:
    title:
      type: string(255)
      notnull: true
    utm:
      type: string(255)
      notnull: true
    comment:
      type: string(1000)
      notnull: false
    url:
      type: string(20)

DiscountPhone:
  actAs:
    Timestampable: ~
  columns:
    phone:
      type: string(20)
      notnull: true
    discount_id:
      type: integer
      notnull: true
    order_id:
      type: string(255)
      notnull: false
      default: null
    active_discount:
      type: integer
      notnull: true
      default: 3
  relations:
    BasketOrder:
      onDelete: SET NULL
      local: order_id
      foreign: id
    Discount:
      onDelete: CASCADE
      local: discount_id
      foreign: id