Manual:Coding conventions/Database
shortcut: CC/DB
Appearance
This page documents a MediaWiki development guideline, crafted over time by developer consensus (or sometimes by proclamation from a lead developer) |
This page describes the coding conventions used within files of the MediaWiki codebase written for usage with a Database. See also the general conventions that apply to all program languages, including those for databases. If you would like a short checklist to help you review your commits, try using the Pre-commit checklist .
MySQL/MariaDB
Use abstract schema for new tables or schema changes. See Manual:Schema changes for more information.
Table naming
- Table names should be singular nouns:
user
,page
,revision
, etc. There are some historical exceptions:pagelinks
,categorylinks
… - Column names are given a prefix derived from the table name: the name itself if it's short, or an abbreviation:
page
→page_id
,page_namespace
,page_title
…categorylinks
→cl_from
,cl_namespace
…
Changing the schema
See Development policy#Database_patches, especially Special:Diff/537762/prev and make sure you use abstract schema changes.