From f47e51d6dea9d59a36a6babf1f4033104c93a53d Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 15 Dec 2012 19:18:26 -0600 Subject: [PATCH] [ticket/11103] Move is_enabled to a separate table for better performance PHPBB3-11103 --- phpBB/config/services.yml | 1 + phpBB/config/tables.yml | 1 + phpBB/develop/create_schema_files.php | 9 +- phpBB/includes/constants.php | 1 + phpBB/includes/notification/manager.php | 98 ++++++++++++------- phpBB/includes/notification/type/base.php | 4 - phpBB/includes/notification/type/bookmark.php | 13 +-- phpBB/includes/notification/type/post.php | 13 +-- phpBB/includes/notification/type/quote.php | 24 ++--- phpBB/install/database_update.php | 11 +++ phpBB/install/schemas/firebird_schema.sql | 13 ++- phpBB/install/schemas/mssql_schema.sql | 28 ++++-- phpBB/install/schemas/mysql_40_schema.sql | 14 ++- phpBB/install/schemas/mysql_41_schema.sql | 14 ++- phpBB/install/schemas/oracle_schema.sql | 18 ++-- phpBB/install/schemas/postgres_schema.sql | 14 ++- phpBB/install/schemas/sqlite_schema.sql | 12 ++- 17 files changed, 187 insertions(+), 101 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index c3e4ee2128..8a8b26ab6b 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -157,6 +157,7 @@ services: - @user - %core.root_path% - %core.php_ext% + - %tables.notification_types% - %tables.notifications% - %tables.user_notifications% diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index 528470d6ca..f5685a7cd9 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,6 +1,7 @@ parameters: tables.config: %core.table_prefix%config tables.ext: %core.table_prefix%ext + tables.notification_types: %core.table_prefix%notification_types tables.notifications: %core.table_prefix%notifications tables.user_notifications: %core.table_prefix%user_notifications tables.users: %core.table_prefix%users diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 87204f9e26..10306c9124 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1295,6 +1295,14 @@ function get_schema_struct() ), ); + $schema_data['phpbb_notification_types'] = array( + 'COLUMNS' => array( + 'notification_type' => array('VCHAR:255', ''), + 'notification_type_enabled' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'), + ); + $schema_data['phpbb_notifications'] = array( 'COLUMNS' => array( 'notification_id' => array('UINT', NULL, 'auto_increment'), @@ -1303,7 +1311,6 @@ function get_schema_struct() 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), - 'is_enabled' => array('BOOL', 1), 'time' => array('TIMESTAMP', 1), 'data' => array('TEXT_UNI', ''), ), diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 7a3c73e987..b8bf517d75 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -239,6 +239,7 @@ define('LOG_TABLE', $table_prefix . 'log'); define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); define('MODERATOR_CACHE_TABLE', $table_prefix . 'moderator_cache'); define('MODULES_TABLE', $table_prefix . 'modules'); +define('NOTIFICATION_TYPES_TABLE', $table_prefix . 'notification_types'); define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); define('POLL_OPTIONS_TABLE', $table_prefix . 'poll_options'); define('POLL_VOTES_TABLE', $table_prefix . 'poll_votes'); diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index a5e1b09754..63db3e6e9a 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -45,13 +45,16 @@ class phpbb_notification_manager /** @var string */ protected $php_ext = null; + /** @var string */ + protected $notification_types_table = null; + /** @var string */ protected $notifications_table = null; /** @var string */ protected $user_notifications_table = null; - public function __construct($notification_types, $notification_methods, $phpbb_container, phpbb_user_loader $user_loader, phpbb_db_driver $db, $user, $phpbb_root_path, $php_ext, $notifications_table, $user_notifications_table) + public function __construct($notification_types, $notification_methods, $phpbb_container, phpbb_user_loader $user_loader, phpbb_db_driver $db, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) { $this->notification_types = $notification_types; $this->notification_methods = $notification_methods; @@ -64,6 +67,7 @@ class phpbb_notification_manager $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + $this->notification_types_table = $notification_types_table; $this->notifications_table = $notifications_table; $this->user_notifications_table = $user_notifications_table; } @@ -121,11 +125,12 @@ class phpbb_notification_manager if ($options['count_unread']) { // Get the total number of unread notifications - $sql = 'SELECT COUNT(*) AS unread_count - FROM ' . $this->notifications_table . ' - WHERE user_id = ' . (int) $options['user_id'] . ' - AND unread = 1 - AND is_enabled = 1'; + $sql = 'SELECT COUNT(n.notification_id) AS unread_count + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt + WHERE n.user_id = ' . (int) $options['user_id'] . ' + AND n.unread = 1 + AND nt.notification_type = n.item_type + AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); $unread_count = (int) $this->db->sql_fetchfield('unread_count', $result); $this->db->sql_freeresult($result); @@ -134,10 +139,11 @@ class phpbb_notification_manager if ($options['count_total']) { // Get the total number of notifications - $sql = 'SELECT COUNT(*) AS total_count - FROM ' . $this->notifications_table . ' - WHERE user_id = ' . (int) $options['user_id'] . ' - AND is_enabled = 1'; + $sql = 'SELECT COUNT(n.notification_id) AS total_count + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt + WHERE n.user_id = ' . (int) $options['user_id'] . ' + AND nt.notification_type = n.item_type + AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); $total_count = (int) $this->db->sql_fetchfield('total_count', $result); $this->db->sql_freeresult($result); @@ -148,12 +154,13 @@ class phpbb_notification_manager $rowset = array(); // Get the main notifications - $sql = 'SELECT * - FROM ' . $this->notifications_table . ' - WHERE user_id = ' . (int) $options['user_id'] . - (($options['notification_id']) ? ((is_array($options['notification_id'])) ? ' AND ' . $this->db->sql_in_set('notification_id', $options['notification_id']) : ' AND notification_id = ' . (int) $options['notification_id']) : '') . ' - AND is_enabled = 1 - ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); + $sql = 'SELECT n.* + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt + WHERE n.user_id = ' . (int) $options['user_id'] . + (($options['notification_id']) ? ((is_array($options['notification_id'])) ? ' AND ' . $this->db->sql_in_set('n.notification_id', $options['notification_id']) : ' AND n.notification_id = ' . (int) $options['notification_id']) : '') . ' + AND nt.notification_type = n.item_type + AND nt.notification_type_enabled = 1 + ORDER BY n.' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); $result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']); while ($row = $this->db->sql_fetchrow($result)) @@ -165,13 +172,14 @@ class phpbb_notification_manager // Get all unread notifications if ($unread_count && $options['all_unread'] && !empty($rowset)) { - $sql = 'SELECT * - FROM ' . $this->notifications_table . ' - WHERE user_id = ' . (int) $options['user_id'] . ' - AND unread = 1 - AND ' . $this->db->sql_in_set('notification_id', array_keys($rowset), true) . ' - AND is_enabled = 1 - ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); + $sql = 'SELECT n.* + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt + WHERE n.user_id = ' . (int) $options['user_id'] . ' + AND n.unread = 1 + AND ' . $this->db->sql_in_set('n.notification_id', array_keys($rowset), true) . ' + AND nt.notification_type = n.item_type + AND nt.notification_type_enabled = 1 + ORDER BY n.' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); $result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']); while ($row = $this->db->sql_fetchrow($result)) @@ -345,6 +353,23 @@ class phpbb_notification_manager return; } + $sql = 'SELECT notification_type + FROM ' . $this->notification_types_table . " + WHERE notification_type = '" . $this->db->sql_escape($item_type) . "'"; + $result = $this->db->sql_query($sql); + + if ($this->db->sql_fetchrow($result) === false) + { + // Does not exist in the database, must add the item type + $sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array( + 'notification_type' => $item_type, + 'notification_type_enabled' => 1, + )); + $this->db->sql_query($sql); + } + + $this->db->sql_freeresult($result); + $item_id = $this->get_item_type_class($item_type)->get_item_id($data); $user_ids = array(); @@ -356,11 +381,12 @@ class phpbb_notification_manager // Make sure not to send new notifications to users who've already been notified about this item // This may happen when an item was added, but now new users are able to see the item - $sql = 'SELECT user_id - FROM ' . $this->notifications_table . " - WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND item_id = " . (int) $item_id . ' - AND is_enabled = 1'; + $sql = 'SELECT n.user_id + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt + WHERE n.item_type = '" . $this->db->sql_escape($item_type) . "' + AND n.item_id = " . (int) $item_id . ' + AND nt.notification_type = n.item_type + AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { @@ -717,9 +743,9 @@ class phpbb_notification_manager */ public function disable_notifications($item_type) { - $sql = 'UPDATE ' . $this->notifications_table . " - SET is_enabled = 0 - WHERE item_type = '" . $this->db->sql_escape($item_type) . "'"; + $sql = 'UPDATE ' . $this->notification_types_table . " + SET notification_type_enabled = 0 + WHERE notification_type = '" . $this->db->sql_escape($item_type) . "'"; $this->db->sql_query($sql); } @@ -736,6 +762,10 @@ class phpbb_notification_manager $sql = 'DELETE FROM ' . $this->notifications_table . " WHERE item_type = '" . $this->db->sql_escape($item_type) . "'"; $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . $this->notification_types_table . " + WHERE notification_type = '" . $this->db->sql_escape($item_type) . "'"; + $this->db->sql_query($sql); } /** @@ -749,9 +779,9 @@ class phpbb_notification_manager */ public function enable_notifications($item_type) { - $sql = 'UPDATE ' . $this->notifications_table . " - SET is_enabled = 1 - WHERE item_type = '" . $this->db->sql_escape($item_type) . "'"; + $sql = 'UPDATE ' . $this->notification_types_table . " + SET notification_type_enabled = 1 + WHERE notification_type = '" . $this->db->sql_escape($item_type) . "'"; $this->db->sql_query($sql); } diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php index 31792de04c..effa57e3a3 100644 --- a/phpBB/includes/notification/type/base.php +++ b/phpBB/includes/notification/type/base.php @@ -72,10 +72,6 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * item_parent_id - Parent item id (ex: for topic => forum_id, for post => topic_id, etc) * user_id * unread - * is_enabled - EXTENSION AUTHORS TAKE NOTE! This is to prevent errors with notifications from extensions! - * - Set is_enabled to 0 for all your notifications when your extension is disabled so they are ignored and do not cause errors. - * - When your extension is enabled again, set is_enabled to 1 and your notifications will be working again. - * * time * data (special serialized field that each notification type can use to store stuff) * diff --git a/phpBB/includes/notification/type/bookmark.php b/phpBB/includes/notification/type/bookmark.php index a17d8f5db7..750bd3b6cb 100644 --- a/phpBB/includes/notification/type/bookmark.php +++ b/phpBB/includes/notification/type/bookmark.php @@ -101,12 +101,13 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); - $sql = 'SELECT * - FROM ' . $this->notifications_table . " - WHERE item_type = '" . $this->get_type() . "' - AND item_parent_id = " . (int) self::get_item_parent_id($post) . ' - AND unread = 1 - AND is_enabled = 1'; + $sql = 'SELECT n.* + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt + WHERE n.item_type = '" . $this->get_type() . "' + AND n.item_parent_id = " . (int) self::get_item_parent_id($post) . ' + AND n.unread = 1 + AND nt.notification_type = n.item_type + AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/phpBB/includes/notification/type/post.php b/phpBB/includes/notification/type/post.php index 0646282c94..0a42029f18 100644 --- a/phpBB/includes/notification/type/post.php +++ b/phpBB/includes/notification/type/post.php @@ -122,12 +122,13 @@ class phpbb_notification_type_post extends phpbb_notification_type_base // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); - $sql = 'SELECT * - FROM ' . $this->notifications_table . " - WHERE item_type = '" . $this->get_type() . "' - AND item_parent_id = " . (int) self::get_item_parent_id($post) . ' - AND unread = 1 - AND is_enabled = 1'; + $sql = 'SELECT n.* + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt + WHERE n.item_type = '" . $this->get_type() . "' + AND n.item_parent_id = " . (int) self::get_item_parent_id($post) . ' + AND n.unread = 1 + AND nt.notification_type = n.item_type + AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/phpBB/includes/notification/type/quote.php b/phpBB/includes/notification/type/quote.php index 1796343a0e..b3a347f98c 100644 --- a/phpBB/includes/notification/type/quote.php +++ b/phpBB/includes/notification/type/quote.php @@ -120,12 +120,13 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); - $sql = 'SELECT * - FROM ' . $this->notifications_table . " - WHERE item_type = '" . $this->get_type() . "' - AND item_parent_id = " . (int) self::get_item_parent_id($post) . ' - AND unread = 1 - AND is_enabled = 1'; + $sql = 'SELECT n.* + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt + WHERE n.item_type = '" . $this->get_type() . "' + AND n.item_parent_id = " . (int) self::get_item_parent_id($post) . ' + AND n.unread = 1 + AND nt.notification_type = n.item_type + AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { @@ -151,11 +152,12 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post public function update_notifications($post) { $old_notifications = array(); - $sql = 'SELECT user_id - FROM ' . $this->notifications_table . " - WHERE item_type = '" . $this->get_type() . "' - AND item_id = " . self::get_item_id($post) . ' - AND is_enabled = 1'; + $sql = 'SELECT n.user_id + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt + WHERE n.item_type = '" . $this->get_type() . "' + AND n.item_id = " . self::get_item_id($post) . ' + AND nt.notification_type = n.item_type + AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0250b53a19..ae810e1022 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -93,6 +93,10 @@ if (!defined('LOGIN_ATTEMPT_TABLE')) { define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); } +if (!defined('NOTIFICATION_TYPES_TABLE')) +{ + define('NOTIFICATION_TYPES_TABLE', $table_prefix . 'notification_types'); +} if (!defined('NOTIFICATIONS_TABLE')) { define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); @@ -1179,6 +1183,13 @@ function database_update_info() 'ext_name' => array('UNIQUE', 'ext_name'), ), ), + NOTIFICATION_TYPES_TABLE => array( + 'COLUMNS' => array( + 'notification_type' => array('VCHAR:255', ''), + 'notification_type_enabled' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'), + ), NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( 'notification_id' => array('UINT', NULL, 'auto_increment'), diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index d3058fb0dd..5f7d23e411 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -618,6 +618,15 @@ BEGIN END;; +# Table: 'phpbb_notification_types' +CREATE TABLE phpbb_notification_types ( + notification_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + notification_type_enabled INTEGER DEFAULT 1 NOT NULL +);; + +ALTER TABLE phpbb_notification_types ADD PRIMARY KEY (notification_type, notification_type_enabled);; + + # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id INTEGER NOT NULL, @@ -626,7 +635,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, unread INTEGER DEFAULT 1 NOT NULL, - is_enabled INTEGER DEFAULT 1 NOT NULL, time INTEGER DEFAULT 1 NOT NULL, data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; @@ -1243,9 +1251,6 @@ CREATE TABLE phpbb_user_notifications ( ALTER TABLE phpbb_user_notifications ADD PRIMARY KEY (item_type, item_id, user_id, method);; -CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications(item_type);; -CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications(user_id);; -CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications(notify);; # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 377ff92620..15529cde38 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -751,6 +751,24 @@ CREATE INDEX [class_left_id] ON [phpbb_modules]([module_class], [left_id]) ON [ GO +/* + Table: 'phpbb_notification_types' +*/ +CREATE TABLE [phpbb_notification_types] ( + [notification_type] [varchar] (255) DEFAULT ('') NOT NULL , + [notification_type_enabled] [int] DEFAULT (1) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_notification_types] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_notification_types] PRIMARY KEY CLUSTERED + ( + [notification_type], + [notification_type_enabled] + ) ON [PRIMARY] +GO + + /* Table: 'phpbb_notifications' */ @@ -761,7 +779,6 @@ CREATE TABLE [phpbb_notifications] ( [item_parent_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , [unread] [int] DEFAULT (1) NOT NULL , - [is_enabled] [int] DEFAULT (1) NOT NULL , [time] [int] DEFAULT (1) NOT NULL , [data] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] @@ -1528,15 +1545,6 @@ ALTER TABLE [phpbb_user_notifications] WITH NOCHECK ADD ) ON [PRIMARY] GO -CREATE INDEX [it] ON [phpbb_user_notifications]([item_type]) ON [PRIMARY] -GO - -CREATE INDEX [uid] ON [phpbb_user_notifications]([user_id]) ON [PRIMARY] -GO - -CREATE INDEX [no] ON [phpbb_user_notifications]([notify]) ON [PRIMARY] -GO - /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 4ceb664cd3..f295664c64 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -430,6 +430,14 @@ CREATE TABLE phpbb_modules ( ); +# Table: 'phpbb_notification_types' +CREATE TABLE phpbb_notification_types ( + notification_type varbinary(255) DEFAULT '' NOT NULL, + notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + PRIMARY KEY (notification_type, notification_type_enabled) +); + + # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, @@ -438,7 +446,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data blob NOT NULL, PRIMARY KEY (notification_id), @@ -875,10 +882,7 @@ CREATE TABLE phpbb_user_notifications ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varbinary(255) DEFAULT '' NOT NULL, notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (item_type, item_id, user_id, method), - KEY it (item_type), - KEY uid (user_id), - KEY no (notify) + PRIMARY KEY (item_type, item_id, user_id, method) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 423b97567a..bfba8e5f64 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -430,6 +430,14 @@ CREATE TABLE phpbb_modules ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +# Table: 'phpbb_notification_types' +CREATE TABLE phpbb_notification_types ( + notification_type varchar(255) DEFAULT '' NOT NULL, + notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + PRIMARY KEY (notification_type, notification_type_enabled) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, @@ -438,7 +446,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data text NOT NULL, PRIMARY KEY (notification_id), @@ -875,10 +882,7 @@ CREATE TABLE phpbb_user_notifications ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varchar(255) DEFAULT '' NOT NULL, notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (item_type, item_id, user_id, method), - KEY it (item_type), - KEY uid (user_id), - KEY no (notify) + PRIMARY KEY (item_type, item_id, user_id, method) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index b3ea3c7d5e..aae49afd70 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -840,6 +840,17 @@ END; / +/* + Table: 'phpbb_notification_types' +*/ +CREATE TABLE phpbb_notification_types ( + notification_type varchar2(255) DEFAULT '' , + notification_type_enabled number(1) DEFAULT '1' NOT NULL, + CONSTRAINT pk_phpbb_notification_types PRIMARY KEY (notification_type, notification_type_enabled) +) +/ + + /* Table: 'phpbb_notifications' */ @@ -850,7 +861,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, unread number(1) DEFAULT '1' NOT NULL, - is_enabled number(1) DEFAULT '1' NOT NULL, time number(11) DEFAULT '1' NOT NULL, data clob DEFAULT '' , CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id) @@ -1642,12 +1652,6 @@ CREATE TABLE phpbb_user_notifications ( ) / -CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type) -/ -CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id) -/ -CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify) -/ /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index e43b64468d..05533fc731 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -596,6 +596,16 @@ CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); +/* + Table: 'phpbb_notification_types' +*/ +CREATE TABLE phpbb_notification_types ( + notification_type varchar(255) DEFAULT '' NOT NULL, + notification_type_enabled INT2 DEFAULT '1' NOT NULL CHECK (notification_type_enabled >= 0), + PRIMARY KEY (notification_type, notification_type_enabled) +); + + /* Table: 'phpbb_notifications' */ @@ -608,7 +618,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0), - is_enabled INT2 DEFAULT '1' NOT NULL CHECK (is_enabled >= 0), time INT4 DEFAULT '1' NOT NULL CHECK (time >= 0), data varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (notification_id) @@ -1128,9 +1137,6 @@ CREATE TABLE phpbb_user_notifications ( PRIMARY KEY (item_type, item_id, user_id, method) ); -CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type); -CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id); -CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify); /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index e3b556668d..fa61e4104f 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -417,6 +417,14 @@ CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); +# Table: 'phpbb_notification_types' +CREATE TABLE phpbb_notification_types ( + notification_type varchar(255) NOT NULL DEFAULT '', + notification_type_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1', + PRIMARY KEY (notification_type, notification_type_enabled) +); + + # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id INTEGER PRIMARY KEY NOT NULL , @@ -425,7 +433,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', unread INTEGER UNSIGNED NOT NULL DEFAULT '1', - is_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1', time INTEGER UNSIGNED NOT NULL DEFAULT '1', data text(65535) NOT NULL DEFAULT '' ); @@ -851,9 +858,6 @@ CREATE TABLE phpbb_user_notifications ( PRIMARY KEY (item_type, item_id, user_id, method) ); -CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type); -CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id); -CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify); # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group (