MySQL Forums
Forum List  »  MySQL Workbench

Synchronize Model still drops and re-adds foreign keys even if nothing has changed
Posted by: Hans Meisenkasper
Date: April 07, 2020 09:33AM

Workbench 8.0.19 on Windows 10
MySql Server 8.0.19 on Windows 10 / Ubuntu


The synchronize model function acts strange.
I created a very simple model and synchronized it with the target database which created the schema fine.

If I immediately synchronize the model again, the database is suddenly out of sync and it is suggested to drop all existing foreign keys and add them again. If I synchronize again the same is happening and again and again...

Why is this happening?


=== Here is the code generated after at the first synchronize model to create the schema in the database:
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;

CREATE TABLE IF NOT EXISTS `mydb`.`cars` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`something` VARCHAR(45) NULL DEFAULT NULL,
`company_id` INT(11) NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_cars_company_idx` (`company_id` ASC) VISIBLE,
CONSTRAINT `fk_cars_company`
FOREIGN KEY (`company_id`)
REFERENCES `mydb`.`company` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;

CREATE TABLE IF NOT EXISTS `mydb`.`company` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`somethingelse` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;

=== Here is the code generated immediately after the first synchronize:
ALTER TABLE `mydb`.`cars`
DROP FOREIGN KEY `fk_cars_company`;

ALTER TABLE `mydb`.`cars`
ADD CONSTRAINT `fk_cars_company`
FOREIGN KEY (`company_id`)
REFERENCES `mydb`.`company` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;

Options: ReplyQuote


Subject
Views
Written By
Posted
Synchronize Model still drops and re-adds foreign keys even if nothing has changed
838
April 07, 2020 09:33AM


Sorry, you can't reply to this topic. It has been closed.

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.