{
  "$schema": "http://json-schema.org/draft-04/schema",
  "type": "object",
  "properties": {
    "table_schema": {
      "id": "#table_schema",
      "type": "string"
    },
    "name": {
      "id": "#name",
      "type": "string"
    },
    "schema": {
      "id": "#schema",
      "type": "object"
    },
    "indexes": {
      "id": "#indexes",
      "description": "Database index definitions",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "cols": {
            "type": "object",
            "patternProperties": {
              ".{1,}": {
                "type": "string"
              }
            }
          },
          "unique": {
            "type": "boolean"
          },
          "concurrently": {
            "type": "boolean"
          }
        },
        "required": [
          "cols"
        ]
      },
      "minItems": 1,
      "maxItems": 10
    },
    "hooks": {
      "type": "object",
      "properties": {
        "hook": {
          "$ref": "#/definitions/hook"
        }
      }
    }
  },
  "required": [
    "name",
    "schema",
    "table_schema"
  ],
  "readonly_attributes": [
    "name",
    "table_schema"
  ],
  "unique_attributes": [
    "name"
  ],
  "definitions": {
    "hook": {
      "id": "#hook",
      "description": "Async jobs for after callbacks",
      "type": "object",
      "patternProperties": {
        "after_[create|update|destroy]": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "run_at": {
                "type": "string"
              },
              "conditions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "name"
            ]
          },
          "minItems": 1,
          "maxItems": 20
        }
      }
    }
  }
}