ALTER TABLE `tbl_007_itens_checklist` DROP FOREIGN KEY `tbl_007_itens_checklist_tbl_005_checklist_ID_CHECKLIST_fk`; ALTER TABLE `tbl_007_itens_checklist` ADD CONSTRAINT `tbl_007_itens_checklist_tbl_005_checklist_ID_CHECKLIST_fk` FOREIGN KEY (`CHECKLIST_ID`) REFERENCES `tbl_005_checklist`(`ID_CHECKLIST`) ON DELETE CASCADE ON UPDATE CASCADE;


//criar fk e cascade delete
ALTER TABLE `tbl_rel_001_pecas_por_servico`
  ADD CONSTRAINT `tbl_rel_001_pecas_por_servico_fk_servico`
FOREIGN KEY (`SERVICO_ID`) REFERENCES `tbl_013_servicos` (`ID_SERVICO`)
  ON DELETE CASCADE
  ON UPDATE CASCADE;

  CREATE TABLE `tbl_rel_002_servico_por_preventiva` (
    `ID_SEVICO_PREVENTIVA` int(11) NOT NULL AUTO_INCREMENT,
    `PREVENTIVA_ID`        int(11)          DEFAULT NULL,
    `SERVICO_ID`           int(11)          DEFAULT NULL,
    PRIMARY KEY (`ID_SEVICO_PREVENTIVA`),
    KEY `tbl_rel_002_servico_por_preventiva_fk_preventiva` (`PREVENTIVA_ID`),
    KEY `tbl_rel_002_servico_por_preventiva_fk_servico` (`SERVICO_ID`),
    CONSTRAINT `tbl_rel_002_servico_por_preventiva_fk_preventiva` FOREIGN KEY (`PREVENTIVA_ID`) REFERENCES `tbl_009_preventiva` (`ID_PREVENTIVA`)
      ON DELETE CASCADE
      ON UPDATE CASCADE,
    CONSTRAINT `tbl_rel_002_servico_por_preventiva_fk_servico` FOREIGN KEY (`SERVICO_ID`) REFERENCES `tbl_013_servicos` (`ID_SERVICO`)
      ON DELETE CASCADE
      ON UPDATE CASCADE
  )
    ENGINE = InnoDB
    AUTO_INCREMENT = 0
    DEFAULT CHARSET = utf8


    CREATE TABLE tbl_rel_003_pecas_por_preventiva
    (
      ID_PECAS_PREVENTIVA INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
      PREVENTIVA_ID       INT(11) NOT NULL,
      PECA_ID             INT(11) NOT NULL,
      CONSTRAINT tbl_rel_003_pecas_por_preventiva_fk_preventiva FOREIGN KEY (PREVENTIVA_ID) REFERENCES tbl_009_preventiva (ID_PREVENTIVA)
        ON DELETE CASCADE
        ON UPDATE CASCADE,
      CONSTRAINT tbl_rel_003_pecas_por_preventiva_fk_peca FOREIGN KEY (PECA_ID) REFERENCES tbl_012_pecas (ID_PECA)
        ON DELETE CASCADE
        ON UPDATE CASCADE
    );
    CREATE INDEX tbl_rel_003_pecas_por_preventiva_fk_preventiva
      ON tbl_rel_003_pecas_por_preventiva (PREVENTIVA_ID);
    CREATE INDEX tbl_rel_003_pecas_por_preventiva_fk_peca
      ON tbl_rel_003_pecas_por_preventiva (PECA_ID);

      //ALTER TABLE tbl_014_agenda CHANGE FUNCIONARIO_ID USUARIO_ID INT(11);
      ALTER TABLE tbl_009_manutencao CHANGE MODELO_ID DT_SOLICITACAO_PECAS DATETIME NOT NULL;