0
Accepted

Allow specify Generation format for MySQL constraints

Nicolás Miranda 1 year ago updated by Olesya 1 year ago 2

I need to forward engineer for MySQL in a different way (to use the script within mysql or h2 in compatible mode)

For that reason I need any of the following ideas.

1) When generating the script don't generate using the keyword 'CONSTRAINT'
Example:

CREATE TABLE `sample`
(
`id` char(36) NOT NULL ,
`parent_id` char(36) DEFAULT NULL ,
`name` varchar(255) DEFAULT NULL ,
PRIMARY KEY (`id`),
KEY `FK_sample_parent_id` (`parent_id`),
CONSTRAINT `FK_sample_parent_id`
FOREIGN KEY `FK_sample_parent_id` (`parent_id`) REFERENCES `sample` (`id`)
);

The CONSTRAINT [name] before the FOREIGN KEY its not need for MYSQL.

2) Allow to create the FK index/constraint using an alter table instead inside the create.

ALTER TABLE sample
ADD CONSTRAINT FK_sample_parent_id FOREIGN KEY (parent_id) REFERENCES sample (id);