volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.66k stars 539 forks source link

Failed to create join table #53

Closed longlongh4 closed 7 years ago

longlongh4 commented 7 years ago

I use Mysql workbench to design tables, the database works fine, but sqlboiler can't recognize the join table. Below is the sql scripts, store_coupons is the join table.

-- -----------------------------------------------------
-- Table `htk_dev`.`coupons`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `htk_dev`.`coupons` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `category` INT(11) NOT NULL DEFAULT '0',
  `user_id` INT(11) NOT NULL,
  `created_at` DATETIME NOT NULL,
  `count` INT(11) NOT NULL,
  `remain_count` INT(11) NOT NULL,
  `content` TEXT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `index_coupons_on_user_id` (`user_id` ASC),
  CONSTRAINT `fk_rails_69b54b3afe`
    FOREIGN KEY (`user_id`)
    REFERENCES `htk_dev`.`users` (`id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

-- -----------------------------------------------------
-- Table `htk_dev`.`stores`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `htk_dev`.`stores` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  `user_id` INT(11) NOT NULL,
  `created_at` DATETIME NOT NULL,
  `updated_at` DATETIME NOT NULL,
  `license_url` VARCHAR(255) NOT NULL,
  `verify` INT(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  INDEX `index_stores_on_user_id` (`user_id` ASC),
  CONSTRAINT `fk_rails_b526db2ffb`
    FOREIGN KEY (`user_id`)
    REFERENCES `htk_dev`.`users` (`id`))
ENGINE = InnoDB
AUTO_INCREMENT = 8
DEFAULT CHARACTER SET = utf8;

-- -----------------------------------------------------
-- Table `htk_dev`.`store_coupons`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `htk_dev`.`store_coupons` (
  `stores_id` INT(11) NOT NULL,
  `coupons_id` INT(11) NOT NULL,
  PRIMARY KEY (`stores_id`, `coupons_id`),
  INDEX `fk_stores_has_coupons_coupons1_idx` (`coupons_id` ASC),
  INDEX `fk_stores_has_coupons_stores1_idx` (`stores_id` ASC),
  CONSTRAINT `fk_stores_has_coupons_coupons1`
    FOREIGN KEY (`coupons_id`)
    REFERENCES `htk_dev`.`coupons` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_stores_has_coupons_stores1`
    FOREIGN KEY (`stores_id`)
    REFERENCES `htk_dev`.`stores` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
longlongh4 commented 7 years ago

Don't know why, when I change to windows version of MySql workbench,all things are fine.