Page MenuHomePhabricator

Allow unit tests to test against different database schemas
Closed, ResolvedPublic

Description

We quite often need to support multiple database schemas for backward compatibility. Since this support may be maintained for a long time, we should have tests that ensure that our code works with the different schema versions. This is motivated by the MCR schema migration, but should help with any kind of schema change.

One way to achieve this is to have a method in MediaWikiTestCase which can be overwritten to return information about which tables are going to be altered, and which SQL files should be used to set up the target schema. This would mean that a test for a class that interacts with the database can have a subclass for each supported database schema.

Care must be taken to restore the original schema after each test class.

Event Timeline

Change 391866 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] Introduce DB schema overrides for unit tests.

https://gerrit.wikimedia.org/r/391866

Change 391866 merged by jenkins-bot:
[mediawiki/core@master] Introduce DB schema overrides for unit tests.

https://gerrit.wikimedia.org/r/391866