Database Schema Names
Reference
Each wiki of an instance is stored in its own database schema. Two properties in xwiki/WEB-INF/xwiki.cfg change how those schemas are named, for an instance that has to fit names someone else decides. Both are read at startup, so a change takes effect on the next restart.
| Property | What it names | Applies to | Shipped as |
|---|---|---|---|
| xwiki.db | The schema of the main wiki | The main wiki only. Every other wiki keeps its own wiki id | Commented out, as xwiki.db=xwiki |
| xwiki.db.prefix | A prefix put in front of the schema name | Every wiki, the main wiki included | Commented out, empty |
The name a wiki gets when xwiki.db is unset
A sub-wiki's schema is its wiki id. The main wiki's is its wiki id too, xwiki on a standard instance, except on the databases that reserve a schema of their own for it:
| Database | Schema of the main wiki |
|---|---|
| HSQLDB | PUBLIC |
| H2 | PUBLIC |
| Apache Derby | APP |
| PostgreSQL, in schema mode, which is the default | public |
| MySQL, MariaDB, Oracle | The wiki id |
The name you configure is not always the name that is used
Whatever the two properties produce is adjusted before it reaches the database, and the adjustment applies to the prefix as well:
- A hyphen becomes an underscore. Many databases do not accept - in a schema name, so a wiki whose id is my-wiki is stored in my_wiki.
- Oracle, H2 and HSQLDB upper-case the result, so the same wiki is MY_WIKI there.
So the schema to look for in a database client is not necessarily the string written in xwiki.cfg or the wiki id shown in the administration.
#-# [Since 1.6M1]
#-# Force the database name for the main wiki.
# xwiki.db=xwiki
#-# [Since 1.6M1]
#-# Add a prefix to all databases names of each wiki.
# xwiki.db.prefix=FAQ
Does setting these properties rename a schema that already exists?
No. They tell XWiki which schema to address; nothing is renamed or copied. Pointing a running instance at a different name makes it look for a schema that is not there, so an existing instance needs the schema renamed in the database first, and a backup before that.
Do sub-wikis have to be schemas rather than databases?
That is a separate setting, xwiki.virtual_mode, which decides whether a sub-wiki is a schema of one database or a database of its own. It changes what "schema name" means above, but not how the two properties here behave.