Merge "Convert to abstract schema"

This commit is contained in:
jenkins-bot 2022-07-13 15:50:40 +00:00 committed by Gerrit Code Review
commit c7f6c1daad
11 changed files with 741 additions and 116 deletions

View file

@ -215,7 +215,7 @@ class Hooks implements RecentChange_saveHook {
$dir = dirname( __DIR__ ) . '/sql'; $dir = dirname( __DIR__ ) . '/sql';
$updater->addExtensionTable( 'echo_event', "$dir/echo.sql" ); $updater->addExtensionTable( 'echo_event', "$dir/$dbType/tables-generated.sql" );
// 1.33 // 1.33
// Can't use addPostDatabaseUpdateMaintenance() here because that would // Can't use addPostDatabaseUpdateMaintenance() here because that would
@ -253,7 +253,7 @@ class Hooks implements RecentChange_saveHook {
// Otherwise they are not created in the place they are accesses, because // Otherwise they are not created in the place they are accesses, because
// DatabaseUpdater does not support other databases other than main wiki schema. // DatabaseUpdater does not support other databases other than main wiki schema.
if ( $wgEchoSharedTrackingCluster === false && $wgEchoSharedTrackingDB === false ) { if ( $wgEchoSharedTrackingCluster === false && $wgEchoSharedTrackingDB === false ) {
$updater->addExtensionTable( 'echo_unread_wikis', "$dir/echo_unread_wikis.sql" ); $updater->addExtensionTable( 'echo_unread_wikis', "$dir/$dbType/tables-sharedtracking-generated.sql" );
// 1.34 (backported) - not for sqlite, the used data type supports the new length // 1.34 (backported) - not for sqlite, the used data type supports the new length
if ( $updater->getDB()->getType() === 'mysql' ) { if ( $updater->getDB()->getType() === 'mysql' ) {

View file

@ -1,96 +0,0 @@
-- Database Schema for Echo notification system
-- An event is a thing that happened that caused one or more users to be notified.
-- For every notified user, there is a corresponding row in the echo_notification table.
CREATE TABLE /*_*/echo_event (
-- Unique auto-increment ID
event_id int unsigned not null primary key auto_increment,
-- Event type; one of the keys in $wgEchoNotifications
event_type varchar(64) binary not null,
-- Unused, always null
event_variant varchar(64) binary null,
-- The agent (user who triggered the event), if any. If the agent is a logged-in user,
-- event_agent_id contains their user ID and event_agent_ip is null. If the agent is
-- an anonymous user , event_agent_ip contains their IP address and event_agent_id is null.
-- If the event doesn't have an agent, both fields are null.
event_agent_id int unsigned null,
event_agent_ip varchar(39) binary null,
-- JSON blob with additional information about the event
event_extra BLOB NULL,
-- Page ID of the page the event happened on, if any (key to page_id)
event_page_id int unsigned null,
-- Whether the event pertains to a deleted page and should be hidden. Events are marked as
-- deleted when the related page is deleted, and unmarked as deleted when the related page
-- is undeleted
event_deleted tinyint unsigned not null default 0
) /*$wgDBTableOptions*/;
-- Index to get only "alert" types or only "message" types
CREATE INDEX /*i*/echo_event_type ON /*_*/echo_event (event_type);
-- Index to find events for a specific page
CREATE INDEX /*i*/echo_event_page_id ON /*_*/echo_event (event_page_id);
-- A notification is a user being notified about a certain event. Multiple users can be notified
-- about the same event.
CREATE TABLE /*_*/echo_notification (
-- Key to event_id
notification_event int unsigned not null,
-- Key to user_id
notification_user int unsigned not null,
-- Timestamp when the notification was created
notification_timestamp binary(14) not null,
-- Timestamp when the user read the notification, or null if unread
notification_read_timestamp binary(14) null,
-- Hash for bundling together similar notifications. Notifications that can be bundled together
-- will have the same hash
notification_bundle_hash varchar(32) binary not null,
PRIMARY KEY (notification_user, notification_event)
) /*$wgDBTableOptions*/;
-- Index to get a user's notifications in chronological order
CREATE INDEX /*i*/echo_user_timestamp ON /*_*/echo_notification (notification_user,notification_timestamp);
-- Used to get all notifications for a given event
CREATE INDEX /*i*/echo_notification_event ON /*_*/echo_notification (notification_event);
-- Used to get read/unread notifications for a user
CREATE INDEX /*i*/echo_notification_user_read_timestamp ON /*_*/echo_notification (notification_user, notification_read_timestamp);
-- Table gathering events for batch emails
-- If a user asks to receive batch emails, events are gathered in this table until it's time to
-- send an email. Once a user has been emailed about an event, it's deleted from this table.
CREATE TABLE /*_*/echo_email_batch (
-- Unique auto-increment ID
eeb_id int unsigned not null primary key auto_increment,
-- Key to user_id
eeb_user_id int unsigned not null,
-- Priority of the event as defined in $wgEchoNotifications; events with lower numbers are listed first
eeb_event_priority tinyint unsigned not null default 10,
-- Key to event_id
eeb_event_id int unsigned not null,
-- Same value as notification_bundle_hash, or a unique value if notification_bundle_hash is empty
eeb_event_hash varchar(32) binary not null
) /*$wgDBTableOptions*/;
-- Used to delete events once they have been processed, and to identify users with events to process
CREATE UNIQUE INDEX /*i*/echo_email_batch_user_event ON /*_*/echo_email_batch (eeb_user_id,eeb_event_id);
-- Used to get a list of events for a user, grouping events with the same hash and ordering by priority
CREATE INDEX /*i*/echo_email_batch_user_hash_priority ON /*_*/echo_email_batch (eeb_user_id, eeb_event_hash, eeb_event_priority);
-- A "target page" of an event is a page that, when the user visits it, causes the event to be
-- marked as read. Typically this is the same as the event's event_page_id, but some events
-- have multiple target pages, and many events don't set a target page at all. An event's
-- target pages are derived from the 'target-page' key in event_extra.
-- This table is also used for moderating events when the related page is deleted,
-- but this should use event_page_id instead (T217452).
CREATE TABLE /*_*/echo_target_page (
-- Unique auto-increment ID
etp_id int unsigned not null primary key auto_increment,
-- Key to page_id
etp_page int unsigned not null default 0,
-- Key to event_id
etp_event int unsigned not null default 0
) /*$wgDBTableOptions*/;
-- Not currently used
CREATE INDEX /*i*/echo_target_page_event ON /*_*/echo_target_page (etp_event);
-- Used to get the events associated with a given page
CREATE INDEX /*i*/echo_target_page_page_event ON /*_*/echo_target_page (etp_page, etp_event);

View file

@ -1,18 +0,0 @@
CREATE TABLE /*_*/echo_unread_wikis (
-- Primary key
euw_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
-- Global user id
euw_user INT UNSIGNED NOT NULL,
-- Name of wiki
euw_wiki VARCHAR(64) NOT NULL,
-- unread alerts count on that wiki
euw_alerts INT UNSIGNED NOT NULL,
-- Timestamp of the most recent unread alert
euw_alerts_ts BINARY(14) NOT NULL,
-- unread messages count on that wiki
euw_messages INT UNSIGNED NOT NULL,
-- Timestamp of the most recent unread message
euw_messages_ts BINARY(14) NOT NULL
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/echo_unread_wikis_user_wiki ON /*_*/echo_unread_wikis (euw_user,euw_wiki);

View file

@ -0,0 +1,94 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: sql/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/echo_event (
event_id INT UNSIGNED AUTO_INCREMENT NOT NULL,
event_type VARBINARY(64) NOT NULL,
event_variant VARBINARY(64) DEFAULT NULL,
event_agent_id INT UNSIGNED DEFAULT NULL,
event_agent_ip VARBINARY(39) DEFAULT NULL,
event_extra BLOB DEFAULT NULL,
event_page_id INT UNSIGNED DEFAULT NULL,
event_deleted TINYINT UNSIGNED DEFAULT 0 NOT NULL,
INDEX echo_event_type (event_type),
INDEX echo_event_page_id (event_page_id),
PRIMARY KEY(event_id)
) /*$wgDBTableOptions*/;
CREATE TABLE /*_*/echo_notification (
notification_event INT UNSIGNED NOT NULL,
notification_user INT UNSIGNED NOT NULL,
notification_timestamp BINARY(14) NOT NULL,
notification_read_timestamp BINARY(14) DEFAULT NULL,
notification_bundle_hash VARBINARY(32) NOT NULL,
INDEX echo_user_timestamp (
notification_user, notification_timestamp
),
INDEX echo_notification_event (notification_event),
INDEX echo_notification_user_read_timestamp (
notification_user, notification_read_timestamp
),
PRIMARY KEY(
notification_user, notification_event
)
) /*$wgDBTableOptions*/;
CREATE TABLE /*_*/echo_email_batch (
eeb_id INT UNSIGNED AUTO_INCREMENT NOT NULL,
eeb_user_id INT UNSIGNED NOT NULL,
eeb_event_priority TINYINT UNSIGNED DEFAULT 10 NOT NULL,
eeb_event_id INT UNSIGNED NOT NULL,
eeb_event_hash VARBINARY(32) NOT NULL,
UNIQUE INDEX echo_email_batch_user_event (eeb_user_id, eeb_event_id),
INDEX echo_email_batch_user_hash_priority (
eeb_user_id, eeb_event_hash, eeb_event_priority
),
PRIMARY KEY(eeb_id)
) /*$wgDBTableOptions*/;
CREATE TABLE /*_*/echo_target_page (
etp_id INT UNSIGNED AUTO_INCREMENT NOT NULL,
etp_page INT UNSIGNED DEFAULT 0 NOT NULL,
etp_event INT UNSIGNED DEFAULT 0 NOT NULL,
INDEX echo_target_page_event (etp_event),
INDEX echo_target_page_page_event (etp_page, etp_event),
PRIMARY KEY(etp_id)
) /*$wgDBTableOptions*/;
CREATE TABLE /*_*/echo_push_provider (
epp_id TINYINT UNSIGNED AUTO_INCREMENT NOT NULL,
epp_name TINYBLOB NOT NULL,
PRIMARY KEY(epp_id)
) /*$wgDBTableOptions*/;
CREATE TABLE /*_*/echo_push_subscription (
eps_id INT UNSIGNED AUTO_INCREMENT NOT NULL,
eps_user INT UNSIGNED NOT NULL,
eps_token BLOB NOT NULL,
eps_token_sha256 CHAR(64) NOT NULL,
eps_provider TINYINT UNSIGNED NOT NULL,
eps_updated TIMESTAMP NOT NULL,
eps_data BLOB DEFAULT NULL,
eps_topic TINYINT UNSIGNED DEFAULT NULL,
UNIQUE INDEX eps_token_sha256 (eps_token_sha256),
INDEX eps_provider (eps_provider),
INDEX eps_topic (eps_topic),
INDEX eps_user (eps_user),
INDEX eps_token (
eps_token(10)
),
PRIMARY KEY(eps_id)
) /*$wgDBTableOptions*/;
CREATE TABLE /*_*/echo_push_topic (
ept_id TINYINT UNSIGNED AUTO_INCREMENT NOT NULL,
ept_text TINYBLOB NOT NULL,
PRIMARY KEY(ept_id)
) /*$wgDBTableOptions*/;

View file

@ -0,0 +1,15 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: sql/tables-sharedtracking.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/echo_unread_wikis (
euw_id INT UNSIGNED AUTO_INCREMENT NOT NULL,
euw_user INT UNSIGNED NOT NULL,
euw_wiki VARCHAR(64) NOT NULL,
euw_alerts INT UNSIGNED NOT NULL,
euw_alerts_ts BINARY(14) NOT NULL,
euw_messages INT UNSIGNED NOT NULL,
euw_messages_ts BINARY(14) NOT NULL,
UNIQUE INDEX echo_unread_wikis_user_wiki (euw_user, euw_wiki),
PRIMARY KEY(euw_id)
) /*$wgDBTableOptions*/;

View file

@ -0,0 +1,106 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: sql/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE echo_event (
event_id SERIAL NOT NULL,
event_type TEXT NOT NULL,
event_variant TEXT DEFAULT NULL,
event_agent_id INT DEFAULT NULL,
event_agent_ip TEXT DEFAULT NULL,
event_extra TEXT DEFAULT NULL,
event_page_id INT DEFAULT NULL,
event_deleted SMALLINT DEFAULT 0 NOT NULL,
PRIMARY KEY(event_id)
);
CREATE INDEX echo_event_type ON echo_event (event_type);
CREATE INDEX echo_event_page_id ON echo_event (event_page_id);
CREATE TABLE echo_notification (
notification_event INT NOT NULL,
notification_user INT NOT NULL,
notification_timestamp TIMESTAMPTZ NOT NULL,
notification_read_timestamp TIMESTAMPTZ DEFAULT NULL,
notification_bundle_hash TEXT NOT NULL,
PRIMARY KEY(
notification_user, notification_event
)
);
CREATE INDEX echo_user_timestamp ON echo_notification (
notification_user, notification_timestamp
);
CREATE INDEX echo_notification_event ON echo_notification (notification_event);
CREATE INDEX echo_notification_user_read_timestamp ON echo_notification (
notification_user, notification_read_timestamp
);
CREATE TABLE echo_email_batch (
eeb_id SERIAL NOT NULL,
eeb_user_id INT NOT NULL,
eeb_event_priority SMALLINT DEFAULT 10 NOT NULL,
eeb_event_id INT NOT NULL,
eeb_event_hash TEXT NOT NULL,
PRIMARY KEY(eeb_id)
);
CREATE UNIQUE INDEX echo_email_batch_user_event ON echo_email_batch (eeb_user_id, eeb_event_id);
CREATE INDEX echo_email_batch_user_hash_priority ON echo_email_batch (
eeb_user_id, eeb_event_hash, eeb_event_priority
);
CREATE TABLE echo_target_page (
etp_id SERIAL NOT NULL,
etp_page INT DEFAULT 0 NOT NULL,
etp_event INT DEFAULT 0 NOT NULL,
PRIMARY KEY(etp_id)
);
CREATE INDEX echo_target_page_event ON echo_target_page (etp_event);
CREATE INDEX echo_target_page_page_event ON echo_target_page (etp_page, etp_event);
CREATE TABLE echo_push_provider (
epp_id SMALLSERIAL NOT NULL,
epp_name TEXT NOT NULL,
PRIMARY KEY(epp_id)
);
CREATE TABLE echo_push_subscription (
eps_id SERIAL NOT NULL,
eps_user INT NOT NULL,
eps_token TEXT NOT NULL,
eps_token_sha256 CHAR(64) NOT NULL,
eps_provider SMALLINT NOT NULL,
eps_updated TIMESTAMPTZ NOT NULL,
eps_data TEXT DEFAULT NULL,
eps_topic SMALLINT DEFAULT NULL,
PRIMARY KEY(eps_id)
);
CREATE UNIQUE INDEX eps_token_sha256 ON echo_push_subscription (eps_token_sha256);
CREATE INDEX eps_provider ON echo_push_subscription (eps_provider);
CREATE INDEX eps_topic ON echo_push_subscription (eps_topic);
CREATE INDEX eps_user ON echo_push_subscription (eps_user);
CREATE INDEX eps_token ON echo_push_subscription (eps_token);
CREATE TABLE echo_push_topic (
ept_id SMALLSERIAL NOT NULL,
ept_text TEXT NOT NULL,
PRIMARY KEY(ept_id)
);

View file

@ -0,0 +1,16 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: sql/tables-sharedtracking.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE echo_unread_wikis (
euw_id SERIAL NOT NULL,
euw_user INT NOT NULL,
euw_wiki VARCHAR(64) NOT NULL,
euw_alerts INT NOT NULL,
euw_alerts_ts TIMESTAMPTZ NOT NULL,
euw_messages INT NOT NULL,
euw_messages_ts TIMESTAMPTZ NOT NULL,
PRIMARY KEY(euw_id)
);
CREATE UNIQUE INDEX echo_unread_wikis_user_wiki ON echo_unread_wikis (euw_user, euw_wiki);

View file

@ -0,0 +1,98 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: sql/tables.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/echo_event (
event_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
event_type BLOB NOT NULL, event_variant BLOB DEFAULT NULL,
event_agent_id INTEGER UNSIGNED DEFAULT NULL,
event_agent_ip BLOB DEFAULT NULL,
event_extra BLOB DEFAULT NULL, event_page_id INTEGER UNSIGNED DEFAULT NULL,
event_deleted SMALLINT UNSIGNED DEFAULT 0 NOT NULL
);
CREATE INDEX echo_event_type ON /*_*/echo_event (event_type);
CREATE INDEX echo_event_page_id ON /*_*/echo_event (event_page_id);
CREATE TABLE /*_*/echo_notification (
notification_event INTEGER UNSIGNED NOT NULL,
notification_user INTEGER UNSIGNED NOT NULL,
notification_timestamp BLOB NOT NULL,
notification_read_timestamp BLOB DEFAULT NULL,
notification_bundle_hash BLOB NOT NULL,
PRIMARY KEY(
notification_user, notification_event
)
);
CREATE INDEX echo_user_timestamp ON /*_*/echo_notification (
notification_user, notification_timestamp
);
CREATE INDEX echo_notification_event ON /*_*/echo_notification (notification_event);
CREATE INDEX echo_notification_user_read_timestamp ON /*_*/echo_notification (
notification_user, notification_read_timestamp
);
CREATE TABLE /*_*/echo_email_batch (
eeb_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
eeb_user_id INTEGER UNSIGNED NOT NULL,
eeb_event_priority SMALLINT UNSIGNED DEFAULT 10 NOT NULL,
eeb_event_id INTEGER UNSIGNED NOT NULL,
eeb_event_hash BLOB NOT NULL
);
CREATE UNIQUE INDEX echo_email_batch_user_event ON /*_*/echo_email_batch (eeb_user_id, eeb_event_id);
CREATE INDEX echo_email_batch_user_hash_priority ON /*_*/echo_email_batch (
eeb_user_id, eeb_event_hash, eeb_event_priority
);
CREATE TABLE /*_*/echo_target_page (
etp_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
etp_page INTEGER UNSIGNED DEFAULT 0 NOT NULL,
etp_event INTEGER UNSIGNED DEFAULT 0 NOT NULL
);
CREATE INDEX echo_target_page_event ON /*_*/echo_target_page (etp_event);
CREATE INDEX echo_target_page_page_event ON /*_*/echo_target_page (etp_page, etp_event);
CREATE TABLE /*_*/echo_push_provider (
epp_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
epp_name BLOB NOT NULL
);
CREATE TABLE /*_*/echo_push_subscription (
eps_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
eps_user INTEGER UNSIGNED NOT NULL,
eps_token BLOB NOT NULL,
eps_token_sha256 CHAR(64) NOT NULL,
eps_provider SMALLINT UNSIGNED NOT NULL,
eps_updated DATETIME NOT NULL,
eps_data BLOB DEFAULT NULL,
eps_topic SMALLINT UNSIGNED DEFAULT NULL
);
CREATE UNIQUE INDEX eps_token_sha256 ON /*_*/echo_push_subscription (eps_token_sha256);
CREATE INDEX eps_provider ON /*_*/echo_push_subscription (eps_provider);
CREATE INDEX eps_topic ON /*_*/echo_push_subscription (eps_topic);
CREATE INDEX eps_user ON /*_*/echo_push_subscription (eps_user);
CREATE INDEX eps_token ON /*_*/echo_push_subscription (eps_token);
CREATE TABLE /*_*/echo_push_topic (
ept_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
ept_text BLOB NOT NULL
);

View file

@ -0,0 +1,15 @@
-- This file is automatically generated using maintenance/generateSchemaSql.php.
-- Source: sql/tables-sharedtracking.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TABLE /*_*/echo_unread_wikis (
euw_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
euw_user INTEGER UNSIGNED NOT NULL,
euw_wiki VARCHAR(64) NOT NULL,
euw_alerts INTEGER UNSIGNED NOT NULL,
euw_alerts_ts BLOB NOT NULL,
euw_messages INTEGER UNSIGNED NOT NULL,
euw_messages_ts BLOB NOT NULL
);
CREATE UNIQUE INDEX echo_unread_wikis_user_wiki ON /*_*/echo_unread_wikis (euw_user, euw_wiki);

View file

@ -0,0 +1,57 @@
[
{
"name": "echo_unread_wikis",
"columns": [
{
"name": "euw_id",
"comment": "Primary key",
"type": "integer",
"options": { "autoincrement": true, "notnull": true, "unsigned": true }
},
{
"name": "euw_user",
"comment": "Global user id",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "euw_wiki",
"comment": "Name of wiki",
"type": "string",
"options": { "notnull": true, "length": 64 }
},
{
"name": "euw_alerts",
"comment": "unread alerts count on that wiki",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "euw_alerts_ts",
"comment": "Timestamp of the most recent unread alert",
"type": "mwtimestamp",
"options": { "notnull": true }
},
{
"name": "euw_messages",
"comment": "unread messages count on that wiki",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "euw_messages_ts",
"comment": "Timestamp of the most recent unread message",
"type": "mwtimestamp",
"options": { "notnull": true }
}
],
"indexes": [
{
"name": "echo_unread_wikis_user_wiki",
"columns": [ "euw_user", "euw_wiki" ],
"unique": true
}
],
"pk": [ "euw_id" ]
}
]

338
sql/tables.json Normal file
View file

@ -0,0 +1,338 @@
[
{
"name": "echo_event",
"comment": "An event is a thing that happened that caused one or more users to be notified. For every notified user, there is a corresponding row in the echo_notification table.",
"columns": [
{
"name": "event_id",
"comment": "Unique auto-increment ID",
"type": "integer",
"options": { "autoincrement": true, "notnull": true, "unsigned": true }
},
{
"name": "event_type",
"comment": "Event type; one of the keys in $wgEchoNotifications",
"type": "binary",
"options": { "notnull": true, "length": 64 }
},
{
"name": "event_variant",
"comment": "Unused, always null",
"type": "binary",
"options": { "notnull": false, "length": 64 }
},
{
"name": "event_agent_id",
"comment": "The agent (user who triggered the event), if any. If the agent is a logged-in user, event_agent_id contains their user ID and event_agent_ip is null. If the agent is an anonymous user, event_agent_ip contains their IP address and event_agent_id is null. If the event doesn't have an agent, both fields are null.",
"type": "integer",
"options": { "notnull": false, "unsigned": true }
},
{
"name": "event_agent_ip",
"comment": "The agent (user who triggered the event), if any. If the agent is a logged-in user, event_agent_id contains their user ID and event_agent_ip is null. If the agent is an anonymous user, event_agent_ip contains their IP address and event_agent_id is null. If the event doesn't have an agent, both fields are null.",
"type": "binary",
"options": { "notnull": false, "length": 39 }
},
{
"name": "event_extra",
"comment": "JSON blob with additional information about the event",
"type": "blob",
"options": { "notnull": false, "length": 65530 }
},
{
"name": "event_page_id",
"comment": "Page ID of the page the event happened on, if any (key to page_id)",
"type": "integer",
"options": { "notnull": false, "unsigned": true }
},
{
"name": "event_deleted",
"comment": "Whether the event pertains to a deleted page and should be hidden. Events are marked as deleted when the related page is deleted, and unmarked as deleted when the related page is undeleted",
"type": "mwtinyint",
"options": { "notnull": true, "unsigned": true, "default": 0 }
}
],
"indexes": [
{
"name": "echo_event_type",
"comment": "Index to get only 'alert' types or only 'message' types",
"columns": [ "event_type" ],
"unique": false
},
{
"name": "echo_event_page_id",
"comment": "Index to find events for a specific page",
"columns": [ "event_page_id" ],
"unique": false
}
],
"pk": [ "event_id" ]
},
{
"name": "echo_notification",
"comment": "A notification is a user being notified about a certain event. Multiple users can be notified about the same event.",
"columns": [
{
"name": "notification_event",
"comment": "Key to event_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "notification_user",
"comment": "Key to user_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "notification_timestamp",
"comment": "Timestamp when the notification was created",
"type": "mwtimestamp",
"options": { "notnull": true }
},
{
"name": "notification_read_timestamp",
"comment": "Timestamp when the user read the notification, or null if unread",
"type": "mwtimestamp",
"options": { "notnull": false }
},
{
"name": "notification_bundle_hash",
"comment": "Hash for bundling together similar notifications. Notifications that can be bundled together will have the same hash",
"type": "binary",
"options": { "notnull": true, "length": 32 }
}
],
"indexes": [
{
"name": "echo_user_timestamp",
"comment": "Index to get a user's notifications in chronological order",
"columns": [ "notification_user", "notification_timestamp" ],
"unique": false
},
{
"name": "echo_notification_event",
"comment": "Used to get all notifications for a given event",
"columns": [ "notification_event" ],
"unique": false
},
{
"name": "echo_notification_user_read_timestamp",
"comment": "Used to get read/unread notifications for a user",
"columns": [ "notification_user", "notification_read_timestamp" ],
"unique": false
}
],
"pk": [ "notification_user", "notification_event" ]
},
{
"name": "echo_email_batch",
"comment": "Table gathering events for batch emails. If a user asks to receive batch emails, events are gathered in this table until it's time to send an email. Once a user has been emailed about an event, it's deleted from this table.",
"columns": [
{
"name": "eeb_id",
"comment": "Unique auto-increment ID",
"type": "integer",
"options": { "autoincrement": true, "notnull": true, "unsigned": true }
},
{
"name": "eeb_user_id",
"comment": "Key to user_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "eeb_event_priority",
"comment": "Priority of the event as defined in $wgEchoNotifications; events with lower numbers are listed first",
"type": "mwtinyint",
"options": { "notnull": true, "unsigned": true, "default": 10 }
},
{
"name": "eeb_event_id",
"comment": "Key to event_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "eeb_event_hash",
"comment": "Same value as notification_bundle_hash, or a unique value if notification_bundle_hash is empty",
"type": "binary",
"options": { "notnull": true, "length": 32 }
}
],
"indexes": [
{
"name": "echo_email_batch_user_event",
"comment": "Used to delete events once they have been processed, and to identify users with events to process",
"columns": [ "eeb_user_id", "eeb_event_id" ],
"unique": true
},
{
"name": "echo_email_batch_user_hash_priority",
"comment": "Used to get a list of events for a user, grouping events with the same hash and ordering by priority",
"columns": [ "eeb_user_id", "eeb_event_hash", "eeb_event_priority" ],
"unique": false
}
],
"pk": [ "eeb_id" ]
},
{
"name": "echo_target_page",
"comment": "A \"target page\" of an event is a page that, when the user visits it, causes the event to be marked as read. Typically this is the same as the event's event_page_id, but some events have multiple target pages, and many events don't set a target page at all. An event's target pages are derived from the 'target-page' key in event_extra. This table is also used for moderating events when the related page is deleted, but this should use event_page_id instead (T217452).",
"columns": [
{
"name": "etp_id",
"comment": "Unique auto-increment ID",
"type": "integer",
"options": { "autoincrement": true, "notnull": true, "unsigned": true }
},
{
"name": "etp_page",
"comment": "Key to page_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true, "default": 0 }
},
{
"name": "etp_event",
"comment": "Key to event_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true, "default": 0 }
}
],
"indexes": [
{
"name": "echo_target_page_event",
"comment": "Not currently used",
"columns": [ "etp_event" ],
"unique": false
},
{
"name": "echo_target_page_page_event",
"comment": "Used to get the events associated with a given page",
"columns": [ "etp_page", "etp_event" ],
"unique": false
}
],
"pk": [ "etp_id" ]
},
{
"name": "echo_push_provider",
"comment": "Table for normalizing push providers; intended for use with the NameTableStore construct.",
"columns": [
{
"name": "epp_id",
"type": "mwtinyint",
"options": { "autoincrement": true, "notnull": true, "unsigned": true }
},
{
"name": "epp_name",
"comment": "push provider name; expected values are 'fcm' and 'apns'",
"type": "blob",
"options": { "notnull": true, "length": 255 }
}
],
"indexes": [],
"pk": [ "epp_id" ]
},
{
"name": "echo_push_subscription",
"comment": "Stores push subscriptions associated with wiki users.",
"columns": [
{
"name": "eps_id",
"type": "integer",
"options": { "autoincrement": true, "notnull": true, "unsigned": true }
},
{
"name": "eps_user",
"comment": "central user ID",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "eps_token",
"comment": "platform-provided push subscription token",
"type": "blob",
"options": { "notnull": true, "length": 65530 }
},
{
"name": "eps_token_sha256",
"comment": "SHA256 digest of the push subscription token (to be used as a uniqueness constraint, since the tokens themselves may be large)",
"type": "string",
"options": { "notnull": true, "length": 64, "fixed": true }
},
{
"name": "eps_provider",
"comment": "push provider ID, expected to reference values 'fcm' or 'apns'",
"type": "mwtinyint",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "eps_updated",
"comment": "last updated timestamp",
"type": "datetimetz",
"options": { "notnull": true, "PlatformOptions": { "version": true } }
},
{
"name": "eps_data",
"comment": "push subscription metadata (e.g APNS notification topic)",
"type": "blob",
"options": { "notnull": false, "length": 65530 }
},
{
"name": "eps_topic",
"comment": "APNS topic ID, references a row ID (ept_id) from echo_push_topic",
"type": "mwtinyint",
"options": { "notnull": false, "unsigned": true }
}
],
"indexes": [
{
"name": "eps_token_sha256",
"columns": [ "eps_token_sha256" ],
"unique": true
},
{
"name": "eps_provider",
"columns": [ "eps_provider" ],
"unique": false
},
{
"name": "eps_topic",
"columns": [ "eps_topic" ],
"unique": false
},
{
"name": "eps_user",
"columns": [ "eps_user" ],
"unique": false
},
{
"name": "eps_token",
"columns": [ "eps_token" ],
"options": { "lengths": [ 10 ] },
"unique": false
}
],
"pk": [ "eps_id" ]
},
{
"name": "echo_push_topic",
"comment": "Table for normalizing APNS push message topics, for use with the NameTableStore construct.",
"columns": [
{
"name": "ept_id",
"type": "mwtinyint",
"options": { "autoincrement": true, "notnull": true, "unsigned": true }
},
{
"name": "ept_text",
"comment": "full topic text",
"type": "blob",
"options": { "notnull": true, "length": 255 }
}
],
"indexes": [],
"pk": [ "ept_id" ]
}
]