qb icon indicating copy to clipboard operation
qb copied to clipboard

CreateAll() should order creations based on foreign keys

Open cdevienne opened this issue 9 years ago • 1 comments

The current implementation create tables in the order they were added to the metadata. It obliges the user to add the tables in the right order, which can become cumbersome on big models.

Moreover, in case of cross-referenced tables, the table creation will fail altogether, when it should defer the foreign key constraints creation.

cdevienne avatar Sep 07 '16 09:09 cdevienne

Hi @cdevienne. The table metadata should create tables first, then add foreign key constraints. Therefore, we wont't need any dependency order detection. I can change this. Here's an example;

CREATE TABLE `table1` (
-- blah blah
);
CREATE TABLE `table2`(
-- blah blah
);

-- blah blah

ALTER TABLE `table1`  
ADD CONSTRAINT `fk_name` 
FOREIGN KEY (`fk_table2_id`) REFERENCES `table2` (`t2`) ON DELETE CASCADE;  

aacanakin avatar Sep 15 '17 14:09 aacanakin