From 1acb816a476777d2b8b03d5e3627789e2aa3994a Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 6 Jun 2017 13:39:14 -0400 Subject: [PATCH] Add constants for schema migration feature flags A general behavior is to progress through four stages: * Access only the old schema (until the schema change is deployed to the databases) * Read and write both schemas (for easy rollback while testing) * Write only the new, read both (while a maintenance script runs to migrate existing old schema to the new) * Access only the new schema (then we can drop the old) This adds constants for use with feature flags controlling these stages. Bug: T166732 Bug: T167246 Change-Id: I0fb637ca8c10ec91d6eda706d9d8a5ce9be41a06 --- includes/Defines.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/includes/Defines.php b/includes/Defines.php index 6bc70edbc5..8ac84e5ab5 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -267,3 +267,28 @@ define( 'CONTENT_FORMAT_XML', 'application/xml' ); */ define( 'SHELL_MAX_ARG_STRLEN', '100000' ); /**@}*/ + +/**@{ + * Schema change migration flags. + * + * Used as values of a feature flag for an orderly transition from an old + * schema to a new schema. + * + * - MIGRATION_OLD: Only read and write the old schema. The new schema need not + * even exist. This is used from when the patch is merged until the schema + * change is actually applied to the database. + * - MIGRATION_WRITE_BOTH: Write both the old and new schema. Read the new + * schema preferentially, falling back to the old. This is used while the + * change is being tested, allowing easy roll-back to the old schema. + * - MIGRATION_WRITE_NEW: Write only the new schema. Read the new schema + * preferentially, falling back to the old. This is used while running the + * maintenance script to migrate existing entries in the old schema to the + * new schema. + * - MIGRATION_NEW: Only read and write the new schema. The old schema (and the + * feature flag) may now be removed. + */ +define( 'MIGRATION_OLD', 0 ); +define( 'MIGRATION_WRITE_BOTH', 1 ); +define( 'MIGRATION_WRITE_NEW', 2 ); +define( 'MIGRATION_NEW', 3 ); +/**@}*/ -- 2.20.1