cubes:
  - name: order_tracking
    sql_table: inventory_v2.order_tracking
    data_source: default

    joins:
      - name: order
        sql: "{CUBE.orderid} = {order.id}"
        relationship: many_to_one

      - name: shipment
        sql: "{CUBE.shipment_id} = {shipment.id}"
        relationship: many_to_one

      - name: site
        sql: "{CUBE.siteid} = {site.id}"
        relationship: many_to_one

    dimensions:
      - name: id
        sql: id
        type: number
        primary_key: true

      - name: custom_tracking_provider
        sql: custom_tracking_provider
        type: string

      - name: externalorderid
        sql: "{CUBE}.`externalOrderId`"
        type: string

      - name: orderid
        sql: "{CUBE}.`orderId`"
        type: string

      - name: shipment_id
        sql: shipment_id
        type: string

      - name: siteid
        sql: "{CUBE}.`siteId`"
        type: string

      - name: status_shipped
        sql: status_shipped
        type: string

      - name: tracking_id
        sql: tracking_id
        type: string

      - name: tracking_link
        sql: tracking_link
        type: string

      - name: tracking_number
        sql: tracking_number
        type: string

      - name: tracking_product_code
        sql: tracking_product_code
        type: string

      - name: tracking_provider
        sql: tracking_provider
        type: string

      - name: createdat
        sql: "{CUBE}.`createdAt`"
        type: time

      - name: updatedat
        sql: "{CUBE}.`updatedAt`"
        type: time

      - name: date_shipped
        sql: date_shipped
        type: time

    measures:
      - name: count
        type: count

    pre_aggregations:
      # Pre-aggregation definitions go here.
      # Learn more in the documentation: https://cube.dev/docs/caching/pre-aggregations/getting-started

