CREATE TABLE IF NOT EXISTS `JSON_SCHEMA_DEPENDENCY` (
  `VERSION_ID` BIGINT NOT NULL,
  `DEPENDS_ON_SCHEMA_ID` BIGINT NOT NULL,
  `DEPENDS_ON_VERSION_ID` BIGINT DEFAULT NULL,
  UNIQUE (`VERSION_ID`, `DEPENDS_ON_SCHEMA_ID`, `DEPENDS_ON_VERSION_ID`),
  CONSTRAINT FOREIGN KEY (`VERSION_ID`) REFERENCES `JSON_SCHEMA_VERSION` (`VERSION_ID`) ON DELETE CASCADE,
  CONSTRAINT FOREIGN KEY (`DEPENDS_ON_SCHEMA_ID`) REFERENCES `JSON_SCHEMA` (`SCHEMA_ID`) ON DELETE RESTRICT,
  CONSTRAINT FOREIGN KEY (`DEPENDS_ON_VERSION_ID`) REFERENCES `JSON_SCHEMA_VERSION` (`VERSION_ID`) ON DELETE RESTRICT
)
