{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://dashremix.com/spec/tracker/1.1.0/tracker@1.schema.json",
 "title": "tracker@1 v1.1.0",
 "description": "One property per table (an array of rows). Generated from schema.sql by spec/build.py. Extension tables (x_<owner>_*) belong to forks and board-derived tables (d_*) to the board that rebuilds them; both are allowed as additional properties.",
 "type": "object",
 "properties": {
  "meta": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "key": {
      "type": [
       "string",
       "null"
      ]
     },
     "value": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [],
    "additionalProperties": false
   }
  },
  "trackers": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "tracker_id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "kind": {
      "type": "string",
      "enum": [
       "check",
       "count",
       "duration",
       "scale",
       "amount"
      ]
     },
     "unit": {
      "type": [
       "string",
       "null"
      ]
     },
     "target": {
      "type": [
       "number",
       "null"
      ]
     },
     "target_period": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "day",
       "week",
       "month",
       null
      ]
     },
     "days_of_week": {
      "type": [
       "integer",
       "null"
      ]
     },
     "active_from": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "archived_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "color_idx": {
      "type": [
       "integer",
       "null"
      ]
     },
     "group": {
      "type": [
       "string",
       "null"
      ]
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "ord": {
      "type": [
       "integer",
       "null"
      ]
     },
     "source": {
      "type": [
       "string",
       "null"
      ]
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "imported_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "role": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "habit",
       "mood",
       "activity",
       null
      ]
     },
     "scale_min": {
      "type": [
       "number",
       "null"
      ]
     },
     "scale_max": {
      "type": [
       "number",
       "null"
      ]
     }
    },
    "required": [
     "tracker_id",
     "name",
     "kind"
    ],
    "additionalProperties": false
   }
  },
  "tracker_targets": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "tracker_id": {
      "type": "string"
     },
     "from_date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "target": {
      "type": "number"
     },
     "target_period": {
      "type": "string",
      "enum": [
       "day",
       "week",
       "month"
      ]
     },
     "days_of_week": {
      "type": [
       "integer",
       "null"
      ]
     },
     "note": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "tracker_id",
     "from_date",
     "target",
     "target_period"
    ],
    "additionalProperties": false
   }
  },
  "entries": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "entry_id": {
      "type": "string"
     },
     "tracker_id": {
      "type": "string"
     },
     "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "value": {
      "type": "number"
     },
     "note": {
      "type": [
       "string",
       "null"
      ]
     },
     "source": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "app",
       "chat",
       "cli",
       "csv",
       "import",
       null
      ]
     },
     "created_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "imported_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "entry_id",
     "tracker_id",
     "date",
     "value"
    ],
    "additionalProperties": false
   }
  },
  "scale_labels": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "tracker_id": {
      "type": "string"
     },
     "value": {
      "type": "number"
     },
     "label": {
      "type": "string"
     }
    },
    "required": [
     "tracker_id",
     "value",
     "label"
    ],
    "additionalProperties": false
   }
  },
  "journal_entries": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "journal_id": {
      "type": "string"
     },
     "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "created_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     },
     "tz": {
      "type": [
       "string",
       "null"
      ]
     },
     "title": {
      "type": [
       "string",
       "null"
      ]
     },
     "body": {
      "type": [
       "string",
       "null"
      ]
     },
     "words": {
      "type": [
       "integer",
       "null"
      ]
     },
     "tags": {
      "type": [
       "string",
       "null"
      ]
     },
     "source": {
      "type": [
       "string",
       "null"
      ]
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "imported_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "journal_id",
     "date"
    ],
    "additionalProperties": false
   }
  },
  "skips": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "skip_id": {
      "type": "string"
     },
     "tracker_id": {
      "type": "string"
     },
     "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "reason": {
      "type": [
       "string",
       "null"
      ]
     },
     "source": {
      "type": [
       "string",
       "null"
      ]
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "imported_at": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?Z$"
     }
    },
    "required": [
     "skip_id",
     "tracker_id",
     "date"
    ],
    "additionalProperties": false
   }
  },
  "data_issues": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "issue_id": {
      "type": "string"
     },
     "severity": {
      "type": "string",
      "enum": [
       "info",
       "warn",
       "error"
      ]
     },
     "kind": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "detail": {
      "type": "string"
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "handling": {
      "type": "string"
     }
    },
    "required": [
     "issue_id",
     "severity",
     "kind",
     "title",
     "detail",
     "handling"
    ],
    "additionalProperties": false
   }
  },
  "annotations": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "annotation_id": {
      "type": "string"
     },
     "target": {
      "type": "string"
     },
     "kind": {
      "type": "string"
     },
     "body": {
      "type": "string"
     },
     "author": {
      "type": [
       "string",
       "null"
      ]
     },
     "source_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "created_at": {
      "type": [
       "string",
       "null"
      ]
     },
     "data_hash": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "annotation_id",
     "target",
     "kind",
     "body"
    ],
    "additionalProperties": false
   }
  },
  "metric_registry": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "metric_id": {
      "type": "string"
     },
     "version": {
      "type": [
       "integer",
       "null"
      ]
     },
     "unit": {
      "type": [
       "string",
       "null"
      ]
     },
     "params": {
      "type": [
       "string",
       "null"
      ]
     },
     "description": {
      "type": [
       "string",
       "null"
      ]
     },
     "sql": {
      "type": [
       "string",
       "null"
      ]
     },
     "test": {
      "type": [
       "string",
       "null"
      ]
     }
    },
    "required": [
     "metric_id"
    ],
    "additionalProperties": false
   }
  }
 },
 "required": [
  "meta",
  "trackers",
  "entries"
 ],
 "patternProperties": {
  "^x_[a-z0-9_]+$": {
   "type": "array"
  },
  "^d_[a-z0-9_]+$": {
   "type": "array"
  }
 },
 "additionalProperties": false
}
