{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ConvertJsonOutput",
  "description": "JSON output for single file convert",
  "type": "object",
  "properties": {
    "conversion": {
      "$ref": "#/$defs/ConversionInfo"
    },
    "dry_run": {
      "type": "boolean"
    },
    "input_file": {
      "type": "string"
    },
    "output_file": {
      "type": ["string", "null"]
    },
    "statistics": {
      "$ref": "#/$defs/ConvertStatistics"
    },
    "warnings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ConvertWarning"
      }
    }
  },
  "required": ["input_file", "conversion", "dry_run", "statistics", "warnings"],
  "$defs": {
    "ConversionInfo": {
      "type": "object",
      "properties": {
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        }
      },
      "required": ["from", "to"]
    },
    "ConvertStatistics": {
      "type": "object",
      "properties": {
        "statements_converted": {
          "type": "integer",
          "minimum": 0
        },
        "statements_processed": {
          "type": "integer",
          "minimum": 0
        },
        "statements_skipped": {
          "type": "integer",
          "minimum": 0
        },
        "statements_unchanged": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "statements_processed",
        "statements_converted",
        "statements_unchanged",
        "statements_skipped"
      ]
    },
    "ConvertWarning": {
      "description": "Warning types that can occur during conversion",
      "oneOf": [
        {
          "description": "Feature not supported in target dialect",
          "type": "object",
          "properties": {
            "feature": {
              "type": "string"
            },
            "suggestion": {
              "type": ["string", "null"]
            },
            "type": {
              "type": "string",
              "const": "unsupported_feature"
            }
          },
          "required": ["type", "feature"]
        },
        {
          "description": "Data type conversion may lose precision",
          "type": "object",
          "properties": {
            "column": {
              "type": ["string", "null"]
            },
            "from_type": {
              "type": "string"
            },
            "table": {
              "type": ["string", "null"]
            },
            "to_type": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "const": "lossy_conversion"
            }
          },
          "required": ["type", "from_type", "to_type"]
        },
        {
          "description": "Statement was skipped",
          "type": "object",
          "properties": {
            "reason": {
              "type": "string"
            },
            "statement_preview": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "const": "skipped_statement"
            }
          },
          "required": ["type", "reason", "statement_preview"]
        },
        {
          "description": "COPY statement needs conversion (PostgreSQL)",
          "type": "object",
          "properties": {
            "table": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "const": "copy_not_converted"
            }
          },
          "required": ["type", "table"]
        }
      ]
    }
  }
}
