<?xml version="1.0" encoding="windows-1252"?>
<node id="1013229" title="Re^3: dbicdump and relationships" created="2013-01-14 10:01:08" updated="2013-01-14 10:01:08">
<type id="11">
note</type>
<author id="715263">
zwon</author>
<data>
<field name="doctext">
&lt;p&gt;I see that [mod://DBIx::Class::Schema::Loader::DBI::mysql] uses &lt;c&gt;SHOW CREATE TABLE&lt;/c&gt; to get table definition, and then looking for
&lt;c&gt;
CONSTRAINT ... FOREIGN KEY ... REFERENCES ...
&lt;/c&gt;
to get information about foreign keys. I tried to create some tables in mysql and check the output of &lt;c&gt;SHOW CREATE TABLES&lt;/c&gt;:
&lt;c&gt;
mysql&gt; create table foo (id integer primary key, name varchar(10));
Query OK, 0 rows affected (0.01 sec)

mysql&gt; create table boo (id integer primary key, foo_id integer references foo(id));
Query OK, 0 rows affected (0.00 sec)

mysql&gt; create table bar (id integer primary key, foo_id integer, constraint foo_id_fk foreign key (foo_id) references foo(id));
Query OK, 0 rows affected (0.00 sec)

mysql&gt; show create table boo;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                               |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------+
| boo   | CREATE TABLE `boo` (
  `id` int(11) NOT NULL,
  `foo_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql&gt; show create table bar;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                      |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| bar   | CREATE TABLE `bar` (
  `id` int(11) NOT NULL,
  `foo_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `foo_id_fk` (`foo_id`),
  CONSTRAINT `foo_id_fk` FOREIGN KEY (`foo_id`) REFERENCES `foo` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql&gt; drop table foo;
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
mysql&gt; drop table bar;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; drop table foo;
Query OK, 0 rows affected (0.00 sec)
&lt;/c&gt;
&lt;p&gt;As you can see, it looks like mysql silently ignores &lt;c&gt;references&lt;/c&gt; in your SQL statements and doesn't create foreign keys. I would say it is rather nasty behaviour, if it doesn't accept your syntax it should throw an error.</field>
<field name="root_node">
1012551</field>
<field name="parent_node">
1013220</field>
</data>
</node>
