Concrete 7.5+ includes a new XML format for db.xml files. This format is based off of Doctrine DBAL, the database abstraction layer added in Concrete 7.5 It allows for consistent types and nomenclature.
Previously, Concrete used the AXMLS format with codes like C
to represent a varchar column. Doctrine refers to it as a "string" – and you can use string
in the type field instead.
Doctrine XML has other benefits:
- Doctrine XML has support for foreign keys, comments and other functionality that AXMLS didn't support as nicely.
- You can easily use Doctrine XML in other (non Concrete) projects to manage database structures. It can be installed easily via composer.
Doctrine XML Github Repository
Since Doctrine XML is its own self-contained third party library, it can be found on github here:
https://github.com/concretecms/doctrine-xml
Example
Here's an example of creating the Users table in Doctrine XML.
<?xml version="1.0" encoding="UTF-8"?>
<schema
xmlns="http://www.concrete5.org/doctrine-xml/0.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.concrete5.org/doctrine-xml/0.5 https://concretecms.github.io/doctrine-xml/doctrine-xml-0.5.xsd">
<table name="Users">
<field name="uID" type="integer" size="10">
<unsigned/>
<autoincrement/>
<key/>
</field>
<field name="uName" type="string" size="64">
<notnull/>
</field>
<field name="uEmail" type="string" size="254">
<notnull/>
</field>
<field name="uPassword" type="string" size="255">
<notnull/>
</field>
<field name="uIsActive" type="string" size="1">
<default value="0"/>
<notnull/>
</field>
<field name="uIsValidated" type="boolean">
<default value="-1"/>
<notnull/>
</field>
<field name="uIsFullRecord" type="boolean">
<default value="1"/>
<notnull/>
</field>
<field name="uDateAdded" type="datetime">
<default value="0000-00-00 00:00:00"/>
<notnull/>
</field>
<field name="uLastPasswordChange" type="datetime">
<default value="0000-00-00 00:00:00"/>
<notnull/>
</field>
<field name="uHasAvatar" type="boolean">
<default value="0"/>
<notnull/>
</field>
<field name="uLastOnline" type="integer" size="10">
<unsigned/>
<default value="0"/>
<notnull/>
</field>
<field name="uLastLogin" type="integer" size="10">
<unsigned/>
<default value="0"/>
<notnull/>
</field>
<field name="uLastIP" type="blob" size="32"/>
<field name="uPreviousLogin" type="integer" size="10">
<unsigned/>
<default value="0"/>
</field>
<field name="uNumLogins" type="integer" size="10">
<unsigned/>
<default value="0"/>
<notnull/>
</field>
<field name="uLastAuthTypeID" type="integer" size="10">
<unsigned/>
<default value="0"/>
<notnull/>
</field>
<field name="uTimezone" type="string" size="255"/>
<field name="uDefaultLanguage" type="string" size="32"/>
<index name="uName">
<unique/>
<col>uName</col>
</index>
<index name="uEmail">
<col>uEmail</col>
</index>
</table>
</schema>
Auto-Detection
Doctrine XML is automatically detected and used when the XML schema contains xmlns="http://www.concrete5.org/doctrine-xml/0.5"
.
Converting from legacy AXML format
If you have an XML file in the old AXML format and you want to convert it to Doctrine XML, you can do it at https://concretecms.github.io/doctrine-xml/.