# dbt schema for the "customers" model
# --------------------------------------------------
# This is a realistic dbt schema.yml.  It uses:
#   - column-level tests (not_null, unique, accepted_values, expression_is_true)
#   - meta: { pii: true } for GDPR-sensitive columns
#   - data_type annotations for type inference
#
# LakeLogic reads this file directly — no manual YAML rewriting needed.
# --------------------------------------------------

version: 2

models:
  - name: customers
    description: >
      Silver-layer customer profiles sourced from the CRM.
      Contains PII and is subject to GDPR right-to-erasure obligations.

    columns:
      - name: customer_id
        description: "Surrogate primary key."
        data_type: integer
        tests:
          - not_null
          - unique

      - name: email
        description: "Contact email — PII."
        data_type: varchar
        meta:
          pii: true
        tests:
          - not_null
          - expression_is_true:
              expression: "email LIKE '%@%'"

      - name: full_name
        description: "Legal full name — PII."
        data_type: varchar
        meta:
          pii: true
        tests:
          - not_null

      - name: phone
        description: "Primary contact number — PII."
        data_type: varchar
        meta:
          pii: true

      - name: date_of_birth
        description: "Date of birth (YYYY-MM-DD) — PII."
        data_type: date
        meta:
          pii: true

      - name: country
        description: "ISO 3166-1 alpha-2 country code."
        data_type: varchar
        tests:
          - not_null
          - accepted_values:
              values: ["GB", "DE", "FR", "NL", "SE", "NO", "DK", "FI", "ES", "IT",
                       "US", "CA", "AU", "NZ", "IN", "SG", "JP"]

      - name: tier
        description: "Subscription tier."
        data_type: varchar
        tests:
          - not_null
          - accepted_values:
              values: ["free", "starter", "growth", "enterprise"]

      - name: total_spend
        description: "Lifetime spend in GBP."
        data_type: double
        tests:
          - not_null
          - expression_is_true:
              expression: "total_spend >= 0"

      - name: created_at
        description: "Account creation timestamp."
        data_type: timestamp
        tests:
          - not_null

      - name: is_active
        description: "Whether the account is currently active."
        data_type: boolean
