version: 2
models:
  - name: CRM_CAMPAIGN_ID_DBT
    description: '{{ doc("CRM_CAMPAIGN_ID_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
    columns:
      - name: ID
        data_tests:
          - not_null
      - name: NAME
        data_tests:
          - not_null
      - name: URL
      - name: ACQUISITION_CHANNEL
        data_tests:
          - not_null
          - accepted_values:
              values: [ 'WYNG',
                        'FILE_UPLOAD_TOOL',
                        'SMF_BESPOKE_ACTIVATION',
                        'SMF_UNCATEGORIZED',
                        'SMF_PLAYLIST_GENERATOR_SPOTIFY_LIBRARY_SCAN',
                        'SMF_PLAYLIST_GENERATOR_QUIZ',
                        'SMF_SOCIAL_SIGNUP_FORM_COMBO',
                        'SMF_NEWSLETTER_SIGNUP',
                        'SMF_FAN_CARD_ACTIVATION',
                        'SMF_GENERAL_PRESAVE',
                        'SMF_GIVEAWAY',
                        'MAKE_THE_LINK',
                        'TUNESPEAK',
                        'SHOPIFY',
                        'MIGRATION',
                        'APPRECIATION_ENGINE',
                        'TICKETING',
                        'FEATURE_FM',
                        'SPOTIFY_SONY_MUSIC_NOW',
                        'PREVIOUS_MAILING_LIST',
                        'SMS_CAMPAIGNS',
                        'SEATED_LIST',
                        'BANDSINTOWN_LIST',
                        'LINKFIRE',
                        'MAESTRO_LIST',
                        'WEBSITE',
                        'PAST_PURCHASERS',
                        'SQWAD',
                        'LEVELLR',
                        'EVENT_SHOP',
                        'MEDALLION',
                        'INTERNAL_SONY_LIST_TRANSFER']
              where: "ACQUISITION_CHANNEL NOT LIKE 'ROSALIA_%'"
      - name: CREATED_AT
        data_tests:
          - not_null
  - name: CRM_CAMPAIGN_ID_FAN_DBT
    description: '{{ doc("CRM_CAMPAIGN_ID_FAN_DBT") }}'
    data_tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - ID
            - FAN_ID
            - GLOBAL_PARTICIPANT_ID
            - CUSTOM_LIST_ID
            - VENDOR_ID
            - SUBACCOUNT_ID
      - dbt_utils.expression_is_true:
          expression: "custom_list_id is not null"
          config:
            where: "global_participant_id is null"
      - dbt_utils.expression_is_true:
          expression: "global_participant_id is not null"
          config:
            where: "custom_list_id is null"
