I am developing a package for Concrete5 that uses AXMLS format to specify the database schema.
http://www.concrete5.org/documentation/how-tos/developers/creating-and-working-with-db-xml-files/
Here is the schema:
<?xml version="1.0"?>
<schema version="0.3">
<table name="notificationCategory">
<field name="id" type="I"> <!-- integer -->
<key/>
<autoincrement/>
</field>
<field name="name" type="C" size="255"> <!-- varchar(255) -->
</field>
<field name="created" type="T">
<deftimestamp/>
</field>
<field name="modified" type="T">
</field>
<opt>
Type=InnoDB
</opt>
</table>
<table name="notificationEntry">
<field name="id" type="I"> <!-- integer -->
<key/>
<autoincrement/>
</field>
<field name="name" type="C" size="255"> <!-- varchar(255) -->
</field>
<field name="cat_id" type="I">
</field>
<constraint>
ADD CONSTRAINT `cat_id_ibfk_1` FOREIGN KEY (`cat_id`) REFERENCES `notificationCategory`.(`id`) ON DELETE CASCADE
</constraint>
<opt>
Type=InnoDB
</opt>
</table>
</schema>
I am struggling with two things:
Foreign keys. The result of the following is a table NotificationEntry where foreign key does not get set (it is using InnoDB)
Default values for created and modified field. I want created to have a default value of the current date, while for modified I'd like to have ON UPDATE CURRENT_TIMESTAMP
show create table notificationCategory; CREATE TABLE `notificationCategory` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1
There is very little documentation available for this format, did anyone have success using it?