Manual:Coding conventions/Database

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

edit

Use abstract schema for new tables or schema changes. See Manual:Schema changes for more information.

Table naming

edit
  • 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:
    • pagepage_id, page_namespace, page_title
    • categorylinkscl_from, cl_namespace

Changing the schema

edit

See Development policy#Database_patches, especially Special:Diff/537762/prev and make sure you use abstract schema changes.