Yurik has uploaded a new change for review. https://gerrit.wikimedia.org/r/199664
Change subject: Reworked database schema ...................................................................... Reworked database schema * Fixed schema per aaron & springle suggestions * For now, moved non-relevant schema files into archive Will need to delete them and remove the index-droping code which is needed to simplify betalabs migration Bug: T93434 Change-Id: I459d04b28965a86f9dd50b4a7b9f628ce192c022 --- M schema/Updater.hooks.php R schema/archive/GatherListPermissions.php R schema/archive/gather_list-perm-ts.sql R schema/archive/gather_list-perm-ts2.sql R schema/archive/gather_list-perm-ts2.sqlite.sql R schema/archive/uninstall.sql M schema/gather_list.sql M schema/gather_list_item.sql 8 files changed, 19 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather refs/changes/64/199664/1 diff --git a/schema/Updater.hooks.php b/schema/Updater.hooks.php index 1caaed4..ba8b93e 100644 --- a/schema/Updater.hooks.php +++ b/schema/Updater.hooks.php @@ -10,19 +10,17 @@ class UpdaterHooks { public static function onLoadExtensionSchemaUpdates( DatabaseUpdater $du ) { $dir = __DIR__; - $du->addExtensionTable( 'gather_list', "$dir/gather_list.sql", true ); - $du->addExtensionTable( 'gather_list_item', "$dir/gather_list_item.sql", true ); - $du->addExtensionField( 'gather_list', 'gl_perm', "$dir/gather_list-perm-ts.sql" ); - require_once "$dir/GatherListPermissions.php"; - $du->addPostDatabaseUpdateMaintenance( 'Gather\GatherListPermissions' ); - - if ( $du->getDB()->getType() === 'sqlite' ) { - $du->modifyExtensionField( 'gather_list', 'gl_perm', "$dir/gather_list-perm-ts2.sqlite.sql" ); - } else { - $du->modifyExtensionField( 'gather_list', 'gl_perm', "$dir/gather_list-perm-ts2.sql" ); + // TODO BUG !!! + // Remove this before going to production - good enough migration for BETA & DEV + if ( $du->getDB()->indexExists( 'gather_list_item', 'gli_id_order_ns_title', __METHOD__ ) ) { + $du->dropExtensionTable( 'gather_list_item', false ); + $du->dropExtensionTable( 'gather_list', false ); } + $du->addExtensionTable( 'gather_list', "$dir/gather_list.sql" ); + $du->addExtensionTable( 'gather_list_item', "$dir/gather_list_item.sql" ); + return true; } } diff --git a/schema/GatherListPermissions.php b/schema/archive/GatherListPermissions.php similarity index 96% rename from schema/GatherListPermissions.php rename to schema/archive/GatherListPermissions.php index 7b2961d..25d924a 100644 --- a/schema/GatherListPermissions.php +++ b/schema/archive/GatherListPermissions.php @@ -13,7 +13,7 @@ if ( $IP === false ) { $IP = __DIR__ . '/../../..'; } -require_once ( "$IP/maintenance/Maintenance.php" ); +require_once( "$IP/maintenance/Maintenance.php" ); /** * @ingroup Maintenance diff --git a/schema/gather_list-perm-ts.sql b/schema/archive/gather_list-perm-ts.sql similarity index 100% rename from schema/gather_list-perm-ts.sql rename to schema/archive/gather_list-perm-ts.sql diff --git a/schema/gather_list-perm-ts2.sql b/schema/archive/gather_list-perm-ts2.sql similarity index 100% rename from schema/gather_list-perm-ts2.sql rename to schema/archive/gather_list-perm-ts2.sql diff --git a/schema/gather_list-perm-ts2.sqlite.sql b/schema/archive/gather_list-perm-ts2.sqlite.sql similarity index 100% rename from schema/gather_list-perm-ts2.sqlite.sql rename to schema/archive/gather_list-perm-ts2.sqlite.sql diff --git a/schema/uninstall.sql b/schema/archive/uninstall.sql similarity index 100% rename from schema/uninstall.sql rename to schema/archive/uninstall.sql diff --git a/schema/gather_list.sql b/schema/gather_list.sql index ca5767f..a3121f8 100644 --- a/schema/gather_list.sql +++ b/schema/gather_list.sql @@ -16,12 +16,12 @@ -- Must be unique per user - makes it easier for querying/looking up gl_label VARCHAR(255) BINARY NOT NULL, - -- The list permissions type (NULL=not migrated, GATHER_PRIVATE=0, GATHER_PUBLIC=1) - -- gl_perm TINYINT UNSIGNED NOT NULL DEFAULT 0, + -- The list permissions type (PRIVATE=0, PUBLIC=1, HIDDEN=2, ...) + gl_perm TINYINT UNSIGNED NOT NULL, -- The timestamp is updated whenever the list's meta data is modified. -- It is possible we might update this field when modifying watchlist / list pages - -- gl_updated VARBINARY(14) NOT NULL DEFAULT '', + gl_updated VARBINARY(14) NOT NULL, -- All other values are stored here to allow for rapid design changes. -- At this point we do not foresee any value in using indexes @@ -36,4 +36,4 @@ -- Show all public lists, sorted by the last updated timestamp -- gl_id is included to allow for safe continuation of the query --- CREATE INDEX /*i*/gl_user_perm_updated ON /*_*/gather_list (gl_perm, gl_updated DESC, gl_id); +CREATE INDEX /*i*/gl_user_perm_updated ON /*_*/gather_list (gl_perm, gl_updated, gl_id); diff --git a/schema/gather_list_item.sql b/schema/gather_list_item.sql index f6b1358..fbf74cb 100644 --- a/schema/gather_list_item.sql +++ b/schema/gather_list_item.sql @@ -17,14 +17,16 @@ -- Sort order uses real to simplify item insertion -- without modifying other items - gli_order FLOAT NOT NULL DEFAULT 0 + gli_order FLOAT NOT NULL ) /*$wgDBTableOptions*/; --- Define clustered index (must be first unique) -- most common operations will enumerate in order -CREATE UNIQUE INDEX /*i*/gli_id_order_ns_title ON /*_*/gather_list_item (gli_gl_id, gli_order, gli_namespace, gli_title); - +-- Clustered unique index (first defined) -- In case all lists for a specific title need to be shown / updated -- Also, enforce one title per list uniqueness CREATE UNIQUE INDEX /*i*/gli_ns_title ON /*_*/gather_list_item (gli_namespace, gli_title, gli_gl_id); + +-- Define index -- enumerate titles in this order +-- Enfoce uniqueness to ensure proper iteration continuation +CREATE UNIQUE INDEX /*i*/gli_id_order ON /*_*/gather_list_item (gli_gl_id, gli_order); -- To view, visit https://gerrit.wikimedia.org/r/199664 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I459d04b28965a86f9dd50b4a7b9f628ce192c022 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Gather Gerrit-Branch: master Gerrit-Owner: Yurik <yu...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits