Add a primary key to the echo_notification table

Take the existing unique index on (user, event) and make it the PK.

Bug: T136428
Change-Id: I659953d80bf3bcf3a6303fa6e09aefed2ecb1987
This commit is contained in:
Roan Kattouw 2016-06-06 19:49:57 +02:00
parent eb98b21dfe
commit fea95cdb49
3 changed files with 6 additions and 2 deletions

View file

@ -177,6 +177,7 @@ class EchoHooks {
$updater->addExtensionIndex( 'echo_notification', 'echo_notification_user_read_timestamp', "$dir/db_patches/patch-add-user_read_timestamp-index.sql" );
$updater->addExtensionIndex( 'echo_target_page', 'echo_target_page_page_event', "$dir/db_patches/patch-add-page_event-index.sql" );
$updater->addExtensionIndex( 'echo_event', 'echo_event_page_id', "$dir/db_patches/patch-add-event_page_id-index.sql" );
$updater->dropExtensionIndex( 'echo_notification', 'user_event', "$dir/db_patches/patch-notification-pk.sql" );
}
/**

View file

@ -0,0 +1,3 @@
DROP INDEX /*i*/user_event ON /*_*/echo_notification;
ALTER TABLE /*_*/echo_notification ADD PRIMARY KEY (notification_user, notification_event);

View file

@ -23,11 +23,11 @@ CREATE TABLE /*_*/echo_notification (
notification_read_timestamp binary(14) null,
notification_bundle_base boolean not null default 1,
notification_bundle_hash varchar(32) binary not null, -- The hash for bundling notifications regardless of timestamp
notification_bundle_display_hash varchar(32) binary not null -- The hash for displaying bundle notifications with regard to timestamp, this is is a subset of notification_bundle_hash
notification_bundle_display_hash varchar(32) binary not null, -- The hash for displaying bundle notifications with regard to timestamp, this is is a subset of notification_bundle_hash
PRIMARY KEY (notification_user, notification_event)
) /*$wgDBTableOptions*/;
CREATE INDEX /*i*/echo_user_timestamp ON /*_*/echo_notification (notification_user,notification_timestamp);
CREATE UNIQUE INDEX /*i*/user_event ON /*_*/echo_notification (notification_user,notification_event);
CREATE INDEX /*i*/echo_notification_user_base_read_timestamp ON /*_*/echo_notification (notification_user, notification_bundle_base, notification_read_timestamp);
CREATE INDEX /*i*/echo_notification_user_base_timestamp ON /*_*/echo_notification (notification_user, notification_bundle_base, notification_timestamp, notification_event);
CREATE INDEX /*i*/echo_notification_user_hash_timestamp ON /*_*/echo_notification (notification_user, notification_bundle_hash, notification_timestamp);