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

    joins:
      - name: customer
        sql: "{CUBE}.customer_id = {customer.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: billing
        sql: billing
        type: string

      - name: cart_hash
        sql: cart_hash
        type: string

      - name: created_via
        sql: created_via
        type: string

      - name: currency
        sql: currency
        type: string

      - name: currency_symbol
        sql: currency_symbol
        type: string

      - name: customer_email
        sql: customer_email
        type: string

      - name: customer_ip_address
        sql: customer_ip_address
        type: string

      - name: customer_note
        sql: customer_note
        type: string

      - name: customer_user_agent
        sql: customer_user_agent
        type: string

      - name: device_type
        sql: device_type
        type: string

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

      - name: meta_data
        sql: meta_data
        type: string

      - name: number
        sql: number
        type: string

      - name: order_key
        sql: order_key
        type: string

      - name: orderstatus
        sql: "{CUBE}.`orderStatus`"
        type: string

      - name: payment_method
        sql: payment_method
        type: string

      - name: payment_method_title
        sql: payment_method_title
        type: string

      - name: payment_url
        sql: payment_url
        type: string

      - name: shipping
        sql: shipping
        type: string

      - name: source_type
        sql: source_type
        type: string

      - name: status
        sql: status
        type: string

      - name: transaction_id
        sql: transaction_id
        type: string

      - name: utm_source
        sql: utm_source
        type: string

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

      - name: date_created
        sql: date_created
        type: time

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

      - name: date_completed
        sql: date_completed
        type: time

      - name: date_modified
        sql: date_modified
        type: time

      - name: date_paid
        sql: date_paid
        type: time

    measures:
      - name: count
        type: count

      - name: discount_total
        sql: discount_total
        type: sum

      - name: shipping_total
        sql: shipping_total
        type: sum

      - name: total
        sql: total
        type: sum

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

