{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dpone.dev/schemas/dpone.dbt-sqlserver-wide-materialization.v1.schema.json",
  "title": "dpone dbt SQL Server wide materialization v1",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema_version": {"const": "dpone.dbt_sqlserver.wide_materialization.v1"},
    "created_at": {"type": "string", "format": "date-time"},
    "release_id": {"type": "string", "minLength": 1},
    "git_head_sha": {"type": "string", "pattern": "^[0-9a-f]{40}$"},
    "source_snapshot_sha256": {"$ref": "#/$defs/digest"},
    "worktree_dirty": {"type": "boolean"},
    "project_sha256": {"$ref": "#/$defs/digest"},
    "mssql_connection_sha256": {"$ref": "#/$defs/digest"},
    "source_relation": {"type": "string", "minLength": 1},
    "output_relation": {"type": "string", "minLength": 1},
    "model_unique_id": {"type": "string", "minLength": 1},
    "materialization": {"const": "table"},
    "source_count": {"type": "integer", "minimum": 0},
    "target_count": {"type": "integer", "minimum": 0},
    "distinct_key_count": {"type": "integer", "minimum": 0},
    "source_column_count": {"type": "integer", "minimum": 0},
    "target_column_count": {"type": "integer", "minimum": 0},
    "schema_mismatch_count": {"type": "integer", "minimum": 0},
    "canonical_source_schema_sha256": {"oneOf": [{"$ref": "#/$defs/digest"}, {"type": "null"}]},
    "canonical_source_mismatch_count": {"type": "integer", "minimum": 0},
    "source_schema_sha256": {"oneOf": [{"$ref": "#/$defs/digest"}, {"type": "null"}]},
    "passthrough_schema_sha256": {"oneOf": [{"$ref": "#/$defs/digest"}, {"type": "null"}]},
    "source_data_sha256": {"oneOf": [{"$ref": "#/$defs/digest"}, {"type": "null"}]},
    "passthrough_data_sha256": {"oneOf": [{"$ref": "#/$defs/digest"}, {"type": "null"}]},
    "output_data_sha256": {"oneOf": [{"$ref": "#/$defs/digest"}, {"type": "null"}]},
    "output_data_rows": {"type": "integer", "minimum": 0},
    "relation_generation_sha256": {"oneOf": [{"$ref": "#/$defs/digest"}, {"type": "null"}]},
    "calculated_column_type": {"type": "string"},
    "calculated_column_nullable": {"type": "boolean"},
    "calculated_mismatch_count": {"type": "integer", "minimum": 0},
    "run_results_path": {"type": ["string", "null"]},
    "run_results_sha256": {"oneOf": [{"$ref": "#/$defs/digest"}, {"type": "null"}]},
    "manifest_path": {"type": ["string", "null"]},
    "manifest_sha256": {"oneOf": [{"$ref": "#/$defs/digest"}, {"type": "null"}]},
    "passed": {"type": "boolean"},
    "error": {"type": ["string", "null"]},
    "environment_class": {"const": "LOCAL_DOCKER"},
    "production_certification": {"const": "UNVERIFIED"},
    "production_certification_reason": {"type": "string", "minLength": 1},
    "evidence_status": {"enum": ["PASS", "UNVERIFIED"]},
    "blockers": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
    "evidence_sha256": {"$ref": "#/$defs/digest"}
  },
  "required": [
    "schema_version",
    "created_at",
    "release_id",
    "git_head_sha",
    "source_snapshot_sha256",
    "worktree_dirty",
    "project_sha256",
    "mssql_connection_sha256",
    "source_relation",
    "output_relation",
    "model_unique_id",
    "materialization",
    "source_count",
    "target_count",
    "distinct_key_count",
    "source_column_count",
    "target_column_count",
    "schema_mismatch_count",
    "canonical_source_schema_sha256",
    "canonical_source_mismatch_count",
    "source_schema_sha256",
    "passthrough_schema_sha256",
    "source_data_sha256",
    "passthrough_data_sha256",
    "output_data_sha256",
    "output_data_rows",
    "relation_generation_sha256",
    "calculated_column_type",
    "calculated_column_nullable",
    "calculated_mismatch_count",
    "run_results_path",
    "run_results_sha256",
    "manifest_path",
    "manifest_sha256",
    "passed",
    "error",
    "environment_class",
    "production_certification",
    "production_certification_reason",
    "evidence_status",
    "blockers",
    "evidence_sha256"
  ],
  "allOf": [
    {
      "if": {"properties": {"passed": {"const": true}}, "required": ["passed"]},
      "then": {
        "properties": {
          "source_schema_sha256": {"$ref": "#/$defs/digest"},
          "canonical_source_schema_sha256": {"$ref": "#/$defs/digest"},
          "passthrough_schema_sha256": {"$ref": "#/$defs/digest"},
          "source_data_sha256": {"$ref": "#/$defs/digest"},
          "passthrough_data_sha256": {"$ref": "#/$defs/digest"},
          "output_data_sha256": {"$ref": "#/$defs/digest"},
          "relation_generation_sha256": {"$ref": "#/$defs/digest"},
          "run_results_path": {"type": "string", "minLength": 1},
          "run_results_sha256": {"$ref": "#/$defs/digest"},
          "manifest_path": {"type": "string", "minLength": 1},
          "manifest_sha256": {"$ref": "#/$defs/digest"}
        }
      }
    }
  ],
  "$defs": {
    "digest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"}
  }
}
