1

enter image description here

Why do I get this weird error when trying to synchronise my model with the mysql database (v5.7.19, workbench v6.3.9)? As you can see from the screenshot, table1_createdOn doesn't even have a default valid, and if i run the generated command with sql query it works:

CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;

CREATE TABLE IF NOT EXISTS `mydb`.`table1` (
  `createdOn` TIMESTAMP NOT NULL,
  PRIMARY KEY (`createdOn`))

CREATE TABLE IF NOT EXISTS `mydb`.`table2` (
  `createdAt` TIMESTAMP NOT NULL,
  `table1_createdOn` TIMESTAMP NOT NULL,
  PRIMARY KEY (`table1_createdOn`),
  CONSTRAINT `fk_round_table1`
    FOREIGN KEY (`table1_createdOn`)
    REFERENCES `mydb`.`table1` (`createdOn`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
Avery235
  • 4,756
  • 12
  • 49
  • 83
  • Although I don't approve of using a timestamp for a primary key, your code works: http://www.sqlfiddle.com/#!9/f732d9. – Gordon Linoff Oct 14 '17 at 02:03
  • I think this [answer](https://stackoverflow.com/questions/35237278/mysql-invalid-default-value-for-timestamp-when-no-default-value-is-given) applies perfectly to your case, if it is so please close it because of duplication. – user10089632 Oct 14 '17 at 02:50
  • Possible duplicate of [MySQL Invalid default value for timestamp when no default value is given.](https://stackoverflow.com/questions/35237278/mysql-invalid-default-value-for-timestamp-when-no-default-value-is-given) – user10089632 Oct 14 '17 at 02:57

0 Answers0