Database schema (deprecated)

Warning

Using the database.xml schema file is deprecated. You should migrate to using Database Migrations.

Nextcloud uses a database abstraction layer on top of either PDO, depending on the availability of PDO on the server.

The database schema is inside appinfo/database.xml in MDB2’s XML scheme notation where the placeholders *dbprefix* (*PREFIX* in your SQL) and *dbname* can be used for the configured database table prefix and database name.

An example database XML file would look like this:

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <database>
  3. <name>*dbname*</name>
  4. <create>true</create>
  5. <overwrite>false</overwrite>
  6. <charset>utf8</charset>
  7. <table>
  8. <name>*dbprefix*yourapp_items</name>
  9. <declaration>
  10. <field>
  11. <name>id</name>
  12. <type>integer</type>
  13. <default>0</default>
  14. <notnull>true</notnull>
  15. <autoincrement>1</autoincrement>
  16. <length>4</length>
  17. </field>
  18. <field>
  19. <name>user</name>
  20. <type>text</type>
  21. <notnull>true</notnull>
  22. <length>64</length>
  23. </field>
  24. <field>
  25. <name>name</name>
  26. <type>text</type>
  27. <notnull>true</notnull>
  28. <length>100</length>
  29. </field>
  30. <field>
  31. <name>path</name>
  32. <type>clob</type>
  33. <notnull>true</notnull>
  34. </field>
  35. </declaration>
  36. </table>
  37. </database>

To update the tables used by the app, simply adjust the database.xml file and increase the app version number in appinfo/info.xml to trigger an update.