MySQL Forums
Forum List  »  MySQL Workbench

MySQL Workbench
Posted by: Rúben Carvalho
Date: April 03, 2020 10:54AM

Hello guys i am with a serious problem. I have already worked with MySQL Workbench but in this version i am having big problem. When I add the setting for Auto Increment in a primary key in the table Owner and do the Forward Engineer, everything is OK.

MySQL Workbench version: 8.0

-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema basededados
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema basededados
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `basededados` DEFAULT CHARACTER SET utf8 ;
USE `basededados` ;

-- -----------------------------------------------------
-- Table `basededados`.`Owner`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `basededados`.`Owner` (
`idOwner` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NULL,
PRIMARY KEY (`idOwner`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `basededados`.`testRack`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `basededados`.`testRack` (
`idTestRack` INT NOT NULL,
`Owner_idOwner` INT NOT NULL,
PRIMARY KEY (`idTestRack`, `Owner_idOwner`),
INDEX `fk_testRack_Owner1_idx` (`Owner_idOwner` ASC) VISIBLE,
CONSTRAINT `fk_testRack_Owner1`
FOREIGN KEY (`Owner_idOwner`)
REFERENCES `basededados`.`Owner` (`idOwner`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `basededados`.`ECU`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `basededados`.`ECU` (
`serialNumber` INT NOT NULL,
`partNumber` VARCHAR(45) NULL,
`softwareVersion` VARCHAR(45) NULL,
`hardwareVersion` VARCHAR(45) NULL,
`designation` VARCHAR(45) NULL,
`date` DATETIME NULL,
`softwareValid` TINYINT NULL,
`hardwareValid` TINYINT NULL,
`Owner_idOwner` INT NOT NULL,
`testRack_idTestRack` INT NOT NULL,
`Owner_idOwner1` INT NOT NULL,
PRIMARY KEY (`serialNumber`, `Owner_idOwner`),
INDEX `fk_ECU_testRack1_idx` (`testRack_idTestRack` ASC) VISIBLE,
INDEX `fk_ECU_Owner1_idx` (`Owner_idOwner1` ASC) VISIBLE,
CONSTRAINT `fk_ECU_testRack1`
FOREIGN KEY (`testRack_idTestRack`)
REFERENCES `basededados`.`testRack` (`idTestRack`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_ECU_Owner1`
FOREIGN KEY (`Owner_idOwner1`)
REFERENCES `basededados`.`Owner` (`idOwner`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `basededados`.`transaction`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `basededados`.`transaction` (
`date` DATETIME NOT NULL,
`testSprint` VARCHAR(45) NOT NULL,
`id_newOwner` INT NOT NULL,
`ECU_serialNumber` INT NOT NULL,
`id_olderOwner` INT NOT NULL,
INDEX `fk_transaction_Owner1_idx` (`id_newOwner` ASC) VISIBLE,
INDEX `fk_transaction_ECU1_idx` (`ECU_serialNumber` ASC, `id_olderOwner` ASC) VISIBLE,
CONSTRAINT `fk_transaction_Owner1`
FOREIGN KEY (`id_newOwner`)
REFERENCES `basededados`.`Owner` (`idOwner`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_transaction_ECU1`
FOREIGN KEY (`ECU_serialNumber` , `id_olderOwner`)
REFERENCES `basededados`.`ECU` (`serialNumber` , `Owner_idOwner`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

However the Auto Increment is not working. If I do the Reverse Engineer the setting Auto Increment is not selected. I can't understand why. Can you help me?

Options: ReplyQuote


Subject
Views
Written By
Posted
MySQL Workbench
189
April 03, 2020 10:54AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.