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

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

      - name: currency
        sql: currency
        type: string

      - name: customer_email
        sql: customer_email
        type: string

      - name: externalsubscriptionid
        sql: "{CUBE}.`externalSubscriptionId`"
        type: string

      - name: line_items
        sql: line_items
        type: string

      - name: meta_data
        sql: meta_data
        type: string

      - name: status
        sql: status
        type: string

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

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

      - name: end_date
        sql: end_date
        type: time

      - name: next_payment_date
        sql: next_payment_date
        type: time

      - name: start_date
        sql: start_date
        type: time

      - name: trial_end
        sql: trial_end
        type: time

    measures:
      - name: count
        type: count

      - 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

