<commit_before>DROP TABLE `articleRevision`;

DROP TABLE `doiAssociation`;

CREATE TABLE `ambra`.`scholarlyWork` (
  `scholarlyWorkId` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `doi` VARCHAR(150) NOT NULL,
  `crepoKey` VARCHAR(255) NOT NULL,
  `crepoUuid` CHAR(36) NOT NULL,
  `scholarlyWorkType` VARCHAR(128) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
  PRIMARY KEY (`scholarlyWorkId`));

CREATE TABLE `ambra`.`scholarlyWorkRelation` (
  `originWorkId` BIGINT(20) NOT NULL,
  `targetWorkId` BIGINT(20) NOT NULL,
  `relationType` VARCHAR(45) NOT NULL,
  INDEX `fk_scholarlyWorkRelation_1_idx` (`originWorkId` ASC),
  INDEX `fk_scholarlyWorkRelation_2_idx` (`targetWorkId` ASC),
  CONSTRAINT `fk_scholarlyWorkRelation_1`
    FOREIGN KEY (`originWorkId`)
    REFERENCES `ambra`.`scholarlyWork` (`scholarlyWorkId`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_scholarlyWorkRelation_2`
    FOREIGN KEY (`targetWorkId`)
    REFERENCES `ambra`.`scholarlyWork` (`scholarlyWorkId`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);

CREATE TABLE `ambra`.`revision` (
  `revisionId` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `scholarlyWorkId` BIGINT(20) NOT NULL,
  `revisionNumber` INT NOT NULL,
  `publicationState` INT NOT NULL,
  PRIMARY KEY (`revisionId`),
  INDEX `fk_revision_1_idx` (`scholarlyWorkId` ASC),
  CONSTRAINT `fk_revision_1`
    FOREIGN KEY (`scholarlyWorkId`)
    REFERENCES `ambra`.`scholarlyWork` (`scholarlyWorkId`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);<commit_msg>DPRO-2347: add uniqueness constraints to new tables and fix uuid CHAR(36) error<commit_after>DROP TABLE `articleRevision`;

DROP TABLE `doiAssociation`;

CREATE TABLE `ambra`.`scholarlyWork` (
  `scholarlyWorkId` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `doi` VARCHAR(150) NOT NULL,
  `crepoKey` VARCHAR(255) NOT NULL,
  `crepoUuid` VARCHAR(36) NOT NULL,
  `scholarlyWorkType` VARCHAR(128) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
  PRIMARY KEY (`scholarlyWorkId`),
  UNIQUE KEY `crepoUuid_UNIQUE` (`crepoUuid`));

CREATE TABLE `ambra`.`scholarlyWorkRelation` (
  `originWorkId` BIGINT(20) NOT NULL,
  `targetWorkId` BIGINT(20) NOT NULL,
  `relationType` VARCHAR(45) NOT NULL,
  UNIQUE KEY `ids_type_UNIQUE` (`originWorkId`, `targetWorkId`, `relationType`),
  INDEX `fk_scholarlyWorkRelation_1_idx` (`originWorkId` ASC),
  INDEX `fk_scholarlyWorkRelation_2_idx` (`targetWorkId` ASC),
  CONSTRAINT `fk_scholarlyWorkRelation_1`
    FOREIGN KEY (`originWorkId`)
    REFERENCES `ambra`.`scholarlyWork` (`scholarlyWorkId`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_scholarlyWorkRelation_2`
    FOREIGN KEY (`targetWorkId`)
    REFERENCES `ambra`.`scholarlyWork` (`scholarlyWorkId`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);

CREATE TABLE `ambra`.`revision` (
  `revisionId` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `scholarlyWorkId` BIGINT(20) NOT NULL,
  `revisionNumber` INT NOT NULL,
  `publicationState` INT NOT NULL,
  PRIMARY KEY (`revisionId`),
  UNIQUE KEY `scholarlyWorkId_UNIQUE` (`scholarlyWorkId`),
  INDEX `fk_revision_1_idx` (`scholarlyWorkId` ASC),
  CONSTRAINT `fk_revision_1`
    FOREIGN KEY (`scholarlyWorkId`)
    REFERENCES `ambra`.`scholarlyWork` (`scholarlyWorkId`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);
{'fraction_non_alphanumeric': 0.11208991494532199, 'fraction_numerical': 0.020656136087484813, 'mean_word_length': 5.52079207920792, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1216436', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1224, 'n_words': 296}