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

    joins:
      - name: order
        sql: "{CUBE}.`orderId` = {order.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: code
        sql: code
        type: string

      - name: discount
        sql: discount
        type: string

      - name: discount_tax
        sql: discount_tax
        type: string

      - name: discount_type
        sql: discount_type
        type: string

      - name: externalordercouponid
        sql: "{CUBE}.`externalOrderCouponId`"
        type: string

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

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

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

    measures:
      - name: count
        type: count

      - name: nominal_amount
        sql: nominal_amount
        type: sum

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

