User:LSobanski (WMF)/Creating new tables
Appearance
This is a draft, use at your own peril
This is an attempt at rewriting Creating_new_tables in a way that is easier to follow. Comments and suggestions are welcome.
Follow the steps below to create a new database table. If you want to make changes to the existing database schema, use this guide instead.
Preparation
- Create a Phabricator task to track the table creation.
- Design the table schema, following the database policy and database coding conventions.
- Create a Gerrit patch with the SQL commands to create the new table and link it to the task.
- Get the patch reviewed (+1):
- Ask a developer knowledgeable in areas of database schema to review the patch (a list is coming, for now just ask around to find one).
- Tag the task with the #DBA tag for visibility. A DBA may provide feedback on the patch at this point.
- Request DBA signoff (requests are processed in order, with no specific SLA, if you are working against a deadline contact the DBA manager to negotiate):
- Add the following information to the task:
- Should this table be replicated to wiki replicas (does it contain private data)?
- Size of the table (number of rows expected).
- Expected growth per year (number of rows).
- Expected amount of queries, both writes and reads (per minute, per hour...per day, any of those are ok).
- Examples of queries that will be using the table.
- The release plan for the feature (are there specific wikis you'd like to test first etc).
- Move the task to the Triage column on the DBA workboard.
- Add the following information to the task:
- Once the two reviews are done, proceed to deployment.
Deployment
- Merge the patch
- Confirm files were deployed to production
- Log on to a mwmaint host (mwmaint1002 or mwmaint2001)
- Check if the file is present in the location matching the following example:
- If :
- the sql file is in
Extension:Foo
in pathsql/new_table.sql
- the MW version deployed in production is
1.36-wmf.21
- the sql file is in
- The location will be:
/srv/mediawiki/php-1.36-wmf.21/extensions/Foo/sql/new_table.sql
- If :
- Schedule table creation at a time that doesn't conflict with the deployment schedule
- Create the table:
- Log on to a mwmaint host (mwmaint1002 or mwmaint2001)
- Run one of the following:
- To add a core table to a single wiki:
mwscript sql.php --wiki=wikidbname maintenance/patches/patchname.sql
- To add a core table to all wikis:
foreachwiki sql.php maintenance/patches/patchname.sql
- To create tables required when adding an extension (assuming you already deployed the extension code):
mwscript extensions/WikimediaMaintenance/createExtensionTables.php --wiki=wikidbname extensionname
- To add a core table to a single wiki:
Future-proofing
- If your new table is going to be needed in all wikis, add it to
addWiki.php
inWikimediaMaintenance
extension so that new wikis are created with your table}}