{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.connectsoft.ai/reference/schemas/blueprint-database.schema.json",
  "title": "Database Blueprint (blueprint-database-v1)",
  "description": "Descriptor document of the Database Blueprint kind (BC-02). Validated by BlueprintService; metadata per blueprint-common.schema.json; generation outputs and validation rules per model/blueprints.yaml.",
  "type": "object",
  "required": [
    "metadata",
    "owningModule",
    "storeClass",
    "profile",
    "backupClass",
    "tables",
    "migrations"
  ],
  "additionalProperties": false,
  "properties": {
    "metadata": {
      "$ref": "blueprint-common.schema.json#/$defs/Metadata"
    },
    "owningModule": {
      "type": "string"
    },
    "storeClass": {
      "type": "string"
    },
    "profile": {
      "type": "string"
    },
    "backupClass": {
      "type": "object",
      "required": [
        "rpoMinutes",
        "rtoMinutes"
      ],
      "properties": {
        "rpoMinutes": {
          "type": "integer"
        },
        "rtoMinutes": {
          "type": "integer"
        }
      },
      "additionalProperties": false
    },
    "tables": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "aggregate",
          "tenantId",
          "classification",
          "columns"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "aggregate": {
            "type": "string"
          },
          "tenantId": {
            "enum": [
              "column",
              "platform-scoped"
            ]
          },
          "classification": {
            "$ref": "blueprint-common.schema.json#/$defs/Classification"
          },
          "retentionDays": {
            "type": "integer"
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "sqlType"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "sqlType": {
                  "type": "string"
                },
                "nullable": {
                  "type": "boolean"
                },
                "pk": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    },
    "migrations": {
      "type": "object",
      "required": [
        "tool",
        "schema"
      ],
      "properties": {
        "tool": {
          "enum": [
            "FluentMigrator"
          ]
        },
        "schema": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  }
}
