Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

drop/createTables

9 views
Skip to first unread message

otop...@gmail.com

unread,
Jul 17, 2014, 7:12:01 AM7/17/14
to qdj...@googlegroups.com
I am using: qdjango v0.4.0-158-g810b021, mysql 5.5.37 on 64bit Linux

I am having problems creating/droping tables from database with functions QDjango::createTables(); and QDjango::dropTables();
It seems that those functions create tables in alphabetical order - it does not care for FK dependencies.

If I have table A which has foreign key to table B:

SQL query "CREATE TABLE `A` (`id` integer `B_id` integer NOT NULL, CONSTRAINT `FK_B_id` FOREIGN KEY (`B_id`) REFERENCES `B` (`id`) ON DELETE RESTRICT)"


Then it ends with error like

SQL error QSqlError("1005", "QMYSQL: Unable to execute query", "Can't create table 'DB.A' (errno: 150)")


There is workaround - to run createTables many times (or until there is no error 150).

It would be nice if the createTables() checked for foreign keys first,
from these FK dependencies created list of tables in right order and then created those tables.
Reply all
Reply to author
Forward
0 new messages