I exported a database from phpmyadmin and the sql formatted like this
CREATE TABLE 'table_1'(
'id' INT UNSIGNED NOT NULL AUTO_INCREMENT,
'name' TEXT NOT NULL
);
ALTER TABLE
'table_1' ADD PRIMARY KEY 'table_1_id_primary'('id');
CREATE TABLE 'table_2'(
'id' INT UNSIGNED NOT NULL AUTO_INCREMENT,
'table_1' INT NOT NULL,
'name' TEXT NOT NULL
);
ALTER TABLE
'table_2' ADD PRIMARY KEY 'table_2_id_primary'('id');
ALTER TABLE
'table_2' ADD INDEX 'table_2_table_1_index'('table_1');
ALTER TABLE
'table_2' ADD CONSTRAINT 'table_2_table_1_foreign' FOREIGN KEY('table_1') REFERENCES 'table_1'('id');
I want to import this database to drawsql. I found out that drawsql can parse Create statement only (It ignores ALTER statements). So I need to convert this script to include the primary key and the foreign keys (relationships) and the indexes inside the create statement. So the previous script would be
CREATE TABLE `table_1`(
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` TEXT NOT NULL
);
CREATE TABLE `table_2`(
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`table_1` INT NOT NULL,
`name` TEXT NOT NULL,
FOREIGN KEY (table_1) REFERENCES table_1(id)
);
Is there an online tool that can do this transformation?
TIA