mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11413] Schema changes and migration file
Notifications tables are dropped because phpBB currently does not have any way to make the necessary changes to the DB schema (and no release has yet been made with these changes). This will fix the following bugs: PHPBB3-11411 PHPBB3-11413 PHPBB3-11414 PHPBB3-11416 PHPBB3-11420 PHPBB3-11413
This commit is contained in:
parent
c182ab0e7b
commit
198b992dce
10 changed files with 304 additions and 115 deletions
|
@ -1317,16 +1317,20 @@ function get_schema_struct()
|
||||||
|
|
||||||
$schema_data['phpbb_notification_types'] = array(
|
$schema_data['phpbb_notification_types'] = array(
|
||||||
'COLUMNS' => array(
|
'COLUMNS' => array(
|
||||||
'notification_type' => array('VCHAR:255', ''),
|
'notification_type_id' => array('USINT', NULL, 'auto_increment'),
|
||||||
|
'notification_type_name' => array('VCHAR:255', ''),
|
||||||
'notification_type_enabled' => array('BOOL', 1),
|
'notification_type_enabled' => array('BOOL', 1),
|
||||||
),
|
),
|
||||||
'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'),
|
'PRIMARY_KEY' => array('notification_type_id'),
|
||||||
|
'KEYS' => array(
|
||||||
|
'type' => array('UNIQUE', array('notification_type_name')),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$schema_data['phpbb_notifications'] = array(
|
$schema_data['phpbb_notifications'] = array(
|
||||||
'COLUMNS' => array(
|
'COLUMNS' => array(
|
||||||
'notification_id' => array('UINT', NULL, 'auto_increment'),
|
'notification_id' => array('UINT:10', NULL, 'auto_increment'),
|
||||||
'item_type' => array('VCHAR:255', ''),
|
'notification_type_id' => array('USINT', 0),
|
||||||
'item_id' => array('UINT', 0),
|
'item_id' => array('UINT', 0),
|
||||||
'item_parent_id' => array('UINT', 0),
|
'item_parent_id' => array('UINT', 0),
|
||||||
'user_id' => array('UINT', 0),
|
'user_id' => array('UINT', 0),
|
||||||
|
@ -1336,7 +1340,7 @@ function get_schema_struct()
|
||||||
),
|
),
|
||||||
'PRIMARY_KEY' => 'notification_id',
|
'PRIMARY_KEY' => 'notification_id',
|
||||||
'KEYS' => array(
|
'KEYS' => array(
|
||||||
'item_ident' => array('INDEX', array('item_type', 'item_id')),
|
'item_ident' => array('INDEX', array('notification_type_id', 'item_id')),
|
||||||
'user' => array('INDEX', array('user_id', 'notification_read')),
|
'user' => array('INDEX', array('user_id', 'notification_read')),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1814,12 +1818,12 @@ function get_schema_struct()
|
||||||
);
|
);
|
||||||
|
|
||||||
$schema_data['phpbb_user_notifications'] = array(
|
$schema_data['phpbb_user_notifications'] = array(
|
||||||
'COLUMNS' => array(
|
'COLUMNS' => array(
|
||||||
'item_type' => array('VCHAR:255', ''),
|
'notification_type_id' => array('USINT', 0),
|
||||||
'item_id' => array('UINT', 0),
|
'item_id' => array('UINT', 0),
|
||||||
'user_id' => array('UINT', 0),
|
'user_id' => array('UINT', 0),
|
||||||
'method' => array('VCHAR:255', ''),
|
'method' => array('VCHAR:255', ''),
|
||||||
'notify' => array('BOOL', 1),
|
'notify' => array('BOOL', 1),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -91,70 +91,6 @@ class phpbb_db_migration_data_310_notifications extends phpbb_db_migration
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
array('config.add', array('load_notifications', 1)),
|
array('config.add', array('load_notifications', 1)),
|
||||||
array('custom', array(array($this, 'convert_notifications'))),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function convert_notifications()
|
|
||||||
{
|
|
||||||
$convert_notifications = array(
|
|
||||||
array(
|
|
||||||
'check' => ($this->config['allow_topic_notify']),
|
|
||||||
'item_type' => 'post',
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'check' => ($this->config['allow_forum_notify']),
|
|
||||||
'item_type' => 'topic',
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'check' => ($this->config['allow_bookmarks']),
|
|
||||||
'item_type' => 'bookmark',
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'check' => ($this->config['allow_privmsg']),
|
|
||||||
'item_type' => 'pm',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($convert_notifications as $convert_data)
|
|
||||||
{
|
|
||||||
if ($convert_data['check'])
|
|
||||||
{
|
|
||||||
$sql = 'SELECT user_id, user_notify_type
|
|
||||||
FROM ' . USERS_TABLE . '
|
|
||||||
WHERE user_notify = 1';
|
|
||||||
$result = $this->db->sql_query($sql);
|
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
$this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array(
|
|
||||||
'item_type' => $convert_data['item_type'],
|
|
||||||
'item_id' => 0,
|
|
||||||
'user_id' => $row['user_id'],
|
|
||||||
'method' => '',
|
|
||||||
)));
|
|
||||||
|
|
||||||
if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH)
|
|
||||||
{
|
|
||||||
$this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array(
|
|
||||||
'item_type' => $convert_data['item_type'],
|
|
||||||
'item_id' => 0,
|
|
||||||
'user_id' => $row['user_id'],
|
|
||||||
'method' => 'email',
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH)
|
|
||||||
{
|
|
||||||
$this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array(
|
|
||||||
'item_type' => $convert_data['item_type'],
|
|
||||||
'item_id' => 0,
|
|
||||||
'user_id' => $row['user_id'],
|
|
||||||
'method' => 'jabber',
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->db->sql_freeresult($result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
206
phpBB/includes/db/migration/data/310/notifications2.php
Normal file
206
phpBB/includes/db/migration/data/310/notifications2.php
Normal file
|
@ -0,0 +1,206 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package migration
|
||||||
|
* @copyright (c) 2012 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration
|
||||||
|
{
|
||||||
|
static public function depends_on()
|
||||||
|
{
|
||||||
|
return array('phpbb_db_migration_data_310_notifications');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_schema()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'drop_tables' => array(
|
||||||
|
$this->table_prefix . 'notification_types',
|
||||||
|
$this->table_prefix . 'notifications',
|
||||||
|
$this->table_prefix . 'user_notifications',
|
||||||
|
),
|
||||||
|
'add_tables' => array(
|
||||||
|
$this->table_prefix . 'notification_types' => array(
|
||||||
|
'COLUMNS' => array(
|
||||||
|
'notification_type_id' => array('USINT', NULL, 'auto_increment'),
|
||||||
|
'notification_type_name' => array('VCHAR:255', ''),
|
||||||
|
'notification_type_enabled' => array('BOOL', 1),
|
||||||
|
),
|
||||||
|
'PRIMARY_KEY' => array('notification_type_id'),
|
||||||
|
'KEYS' => array(
|
||||||
|
'type' => array('UNIQUE', array('notification_type_name')),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
$this->table_prefix . 'notifications' => array(
|
||||||
|
'COLUMNS' => array(
|
||||||
|
'notification_id' => array('UINT:10', NULL, 'auto_increment'),
|
||||||
|
'notification_type_id' => array('USINT', 0),
|
||||||
|
'item_id' => array('UINT', 0),
|
||||||
|
'item_parent_id' => array('UINT', 0),
|
||||||
|
'user_id' => array('UINT', 0),
|
||||||
|
'notification_read' => array('BOOL', 0),
|
||||||
|
'notification_time' => array('TIMESTAMP', 1),
|
||||||
|
'notification_data' => array('TEXT_UNI', ''),
|
||||||
|
),
|
||||||
|
'PRIMARY_KEY' => 'notification_id',
|
||||||
|
'KEYS' => array(
|
||||||
|
'item_ident' => array('INDEX', array('notification_type_id', 'item_id')),
|
||||||
|
'user' => array('INDEX', array('user_id', 'notification_read')),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
$this->table_prefix . 'user_notifications' => array(
|
||||||
|
'COLUMNS' => array(
|
||||||
|
'notification_type_id' => array('USINT', 0),
|
||||||
|
'item_id' => array('UINT', 0),
|
||||||
|
'user_id' => array('UINT', 0),
|
||||||
|
'method' => array('VCHAR:255', ''),
|
||||||
|
'notify' => array('BOOL', 1),
|
||||||
|
),
|
||||||
|
'PRIMARY_KEY' => array(
|
||||||
|
'notification_type_id',
|
||||||
|
'item_id',
|
||||||
|
'user_id',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function revert_schema()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'drop_tables' => array(
|
||||||
|
$this->table_prefix . 'notification_types',
|
||||||
|
$this->table_prefix . 'notifications',
|
||||||
|
$this->table_prefix . 'user_notifications',
|
||||||
|
),
|
||||||
|
'add_tables' => array(
|
||||||
|
$this->table_prefix . 'notification_types' => array(
|
||||||
|
'COLUMNS' => array(
|
||||||
|
'notification_type' => array('VCHAR:255', ''),
|
||||||
|
'notification_type_enabled' => array('BOOL', 1),
|
||||||
|
),
|
||||||
|
'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'),
|
||||||
|
),
|
||||||
|
$this->table_prefix . 'notifications' => array(
|
||||||
|
'COLUMNS' => array(
|
||||||
|
'notification_id' => array('UINT', NULL, 'auto_increment'),
|
||||||
|
'item_type' => array('VCHAR:255', ''),
|
||||||
|
'item_id' => array('UINT', 0),
|
||||||
|
'item_parent_id' => array('UINT', 0),
|
||||||
|
'user_id' => array('UINT', 0),
|
||||||
|
'notification_read' => array('BOOL', 0),
|
||||||
|
'notification_time' => array('TIMESTAMP', 1),
|
||||||
|
'notification_data' => array('TEXT_UNI', ''),
|
||||||
|
),
|
||||||
|
'PRIMARY_KEY' => 'notification_id',
|
||||||
|
'KEYS' => array(
|
||||||
|
'item_ident' => array('INDEX', array('item_type', 'item_id')),
|
||||||
|
'user' => array('INDEX', array('user_id', 'notification_read')),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
$this->table_prefix . 'user_notifications' => array(
|
||||||
|
'COLUMNS' => array(
|
||||||
|
'item_type' => array('VCHAR:255', ''),
|
||||||
|
'item_id' => array('UINT', 0),
|
||||||
|
'user_id' => array('UINT', 0),
|
||||||
|
'method' => array('VCHAR:255', ''),
|
||||||
|
'notify' => array('BOOL', 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_data()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('custom', array(array($this, 'convert_notifications'))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function convert_notifications()
|
||||||
|
{
|
||||||
|
$insert_table = $this->table_prefix . 'user_notifications';
|
||||||
|
|
||||||
|
$sql = 'SELECT user_id, user_notify_type, user_notify_pm
|
||||||
|
FROM ' . USERS_TABLE;
|
||||||
|
$result = $this->db->sql_query($sql);
|
||||||
|
|
||||||
|
$sql_insert_data = array();
|
||||||
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$notification_methods = array();
|
||||||
|
|
||||||
|
// In-board notification
|
||||||
|
$notification_methods[] = '';
|
||||||
|
|
||||||
|
if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH)
|
||||||
|
{
|
||||||
|
$notification_methods[] = 'email';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH)
|
||||||
|
{
|
||||||
|
$notification_methods[] = 'jabber';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notifications for posts
|
||||||
|
foreach (array('post', 'topic') as $item_type)
|
||||||
|
{
|
||||||
|
$sql_insert_data = $this->add_method_rows(
|
||||||
|
$sql_insert_data,
|
||||||
|
$item_type,
|
||||||
|
0,
|
||||||
|
$row['user_id'],
|
||||||
|
$notification_methods
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row['user_notify_pm'])
|
||||||
|
{
|
||||||
|
// Notifications for private messages
|
||||||
|
// User either gets all methods or no method
|
||||||
|
$sql_insert_data = $this->add_method_rows(
|
||||||
|
$sql_insert_data,
|
||||||
|
'pm',
|
||||||
|
0,
|
||||||
|
$row['user_id'],
|
||||||
|
$notification_methods
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sizeof($sql_insert_data) > 500)
|
||||||
|
{
|
||||||
|
$this->db->sql_multi_insert($insert_table, $sql_insert_data);
|
||||||
|
$sql_insert_data = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
|
if (!empty($sql_insert_data))
|
||||||
|
{
|
||||||
|
$this->db->sql_multi_insert($insert_table, $sql_insert_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function add_method_rows(array $sql_insert_data, $item_type, $item_id, $user_id, array $methods)
|
||||||
|
{
|
||||||
|
$row_base = array(
|
||||||
|
'item_type' => $item_type,
|
||||||
|
'item_id' => (int) $item_id,
|
||||||
|
'user_id' => (int) $user_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($methods as $method)
|
||||||
|
{
|
||||||
|
$row_base['method'] = $method;
|
||||||
|
$sql_insert_data[] = $row_base;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql_insert_data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -642,17 +642,30 @@ END;;
|
||||||
|
|
||||||
# Table: 'phpbb_notification_types'
|
# Table: 'phpbb_notification_types'
|
||||||
CREATE TABLE phpbb_notification_types (
|
CREATE TABLE phpbb_notification_types (
|
||||||
notification_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
|
notification_type_id INTEGER NOT NULL,
|
||||||
|
notification_type_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
|
||||||
notification_type_enabled INTEGER DEFAULT 1 NOT NULL
|
notification_type_enabled INTEGER DEFAULT 1 NOT NULL
|
||||||
);;
|
);;
|
||||||
|
|
||||||
ALTER TABLE phpbb_notification_types ADD PRIMARY KEY (notification_type, notification_type_enabled);;
|
ALTER TABLE phpbb_notification_types ADD PRIMARY KEY (notification_type_id);;
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX phpbb_notification_types_type ON phpbb_notification_types(notification_type_name);;
|
||||||
|
|
||||||
|
CREATE GENERATOR phpbb_notification_types_gen;;
|
||||||
|
SET GENERATOR phpbb_notification_types_gen TO 0;;
|
||||||
|
|
||||||
|
CREATE TRIGGER t_phpbb_notification_types FOR phpbb_notification_types
|
||||||
|
BEFORE INSERT
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
NEW.notification_type_id = GEN_ID(phpbb_notification_types_gen, 1);
|
||||||
|
END;;
|
||||||
|
|
||||||
|
|
||||||
# Table: 'phpbb_notifications'
|
# Table: 'phpbb_notifications'
|
||||||
CREATE TABLE phpbb_notifications (
|
CREATE TABLE phpbb_notifications (
|
||||||
notification_id INTEGER NOT NULL,
|
notification_id INTEGER NOT NULL,
|
||||||
item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
|
notification_type_id INTEGER DEFAULT 0 NOT NULL,
|
||||||
item_id INTEGER DEFAULT 0 NOT NULL,
|
item_id INTEGER DEFAULT 0 NOT NULL,
|
||||||
item_parent_id INTEGER DEFAULT 0 NOT NULL,
|
item_parent_id INTEGER DEFAULT 0 NOT NULL,
|
||||||
user_id INTEGER DEFAULT 0 NOT NULL,
|
user_id INTEGER DEFAULT 0 NOT NULL,
|
||||||
|
@ -663,7 +676,7 @@ CREATE TABLE phpbb_notifications (
|
||||||
|
|
||||||
ALTER TABLE phpbb_notifications ADD PRIMARY KEY (notification_id);;
|
ALTER TABLE phpbb_notifications ADD PRIMARY KEY (notification_id);;
|
||||||
|
|
||||||
CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications(item_type, item_id);;
|
CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications(notification_type_id, item_id);;
|
||||||
CREATE INDEX phpbb_notifications_user ON phpbb_notifications(user_id, notification_read);;
|
CREATE INDEX phpbb_notifications_user ON phpbb_notifications(user_id, notification_read);;
|
||||||
|
|
||||||
CREATE GENERATOR phpbb_notifications_gen;;
|
CREATE GENERATOR phpbb_notifications_gen;;
|
||||||
|
@ -1290,7 +1303,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch(notify_status)
|
||||||
|
|
||||||
# Table: 'phpbb_user_notifications'
|
# Table: 'phpbb_user_notifications'
|
||||||
CREATE TABLE phpbb_user_notifications (
|
CREATE TABLE phpbb_user_notifications (
|
||||||
item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
|
notification_type_id INTEGER DEFAULT 0 NOT NULL,
|
||||||
item_id INTEGER DEFAULT 0 NOT NULL,
|
item_id INTEGER DEFAULT 0 NOT NULL,
|
||||||
user_id INTEGER DEFAULT 0 NOT NULL,
|
user_id INTEGER DEFAULT 0 NOT NULL,
|
||||||
method VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
|
method VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
|
||||||
|
|
|
@ -793,7 +793,8 @@ GO
|
||||||
Table: 'phpbb_notification_types'
|
Table: 'phpbb_notification_types'
|
||||||
*/
|
*/
|
||||||
CREATE TABLE [phpbb_notification_types] (
|
CREATE TABLE [phpbb_notification_types] (
|
||||||
[notification_type] [varchar] (255) DEFAULT ('') NOT NULL ,
|
[notification_type_id] [int] IDENTITY (1, 1) NOT NULL ,
|
||||||
|
[notification_type_name] [varchar] (255) DEFAULT ('') NOT NULL ,
|
||||||
[notification_type_enabled] [int] DEFAULT (1) NOT NULL
|
[notification_type_enabled] [int] DEFAULT (1) NOT NULL
|
||||||
) ON [PRIMARY]
|
) ON [PRIMARY]
|
||||||
GO
|
GO
|
||||||
|
@ -801,18 +802,20 @@ GO
|
||||||
ALTER TABLE [phpbb_notification_types] WITH NOCHECK ADD
|
ALTER TABLE [phpbb_notification_types] WITH NOCHECK ADD
|
||||||
CONSTRAINT [PK_phpbb_notification_types] PRIMARY KEY CLUSTERED
|
CONSTRAINT [PK_phpbb_notification_types] PRIMARY KEY CLUSTERED
|
||||||
(
|
(
|
||||||
[notification_type],
|
[notification_type_id]
|
||||||
[notification_type_enabled]
|
|
||||||
) ON [PRIMARY]
|
) ON [PRIMARY]
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX [type] ON [phpbb_notification_types]([notification_type_name]) ON [PRIMARY]
|
||||||
|
GO
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Table: 'phpbb_notifications'
|
Table: 'phpbb_notifications'
|
||||||
*/
|
*/
|
||||||
CREATE TABLE [phpbb_notifications] (
|
CREATE TABLE [phpbb_notifications] (
|
||||||
[notification_id] [int] IDENTITY (1, 1) NOT NULL ,
|
[notification_id] [int] IDENTITY (1, 1) NOT NULL ,
|
||||||
[item_type] [varchar] (255) DEFAULT ('') NOT NULL ,
|
[notification_type_id] [int] DEFAULT (0) NOT NULL ,
|
||||||
[item_id] [int] DEFAULT (0) NOT NULL ,
|
[item_id] [int] DEFAULT (0) NOT NULL ,
|
||||||
[item_parent_id] [int] DEFAULT (0) NOT NULL ,
|
[item_parent_id] [int] DEFAULT (0) NOT NULL ,
|
||||||
[user_id] [int] DEFAULT (0) NOT NULL ,
|
[user_id] [int] DEFAULT (0) NOT NULL ,
|
||||||
|
@ -829,7 +832,7 @@ ALTER TABLE [phpbb_notifications] WITH NOCHECK ADD
|
||||||
) ON [PRIMARY]
|
) ON [PRIMARY]
|
||||||
GO
|
GO
|
||||||
|
|
||||||
CREATE INDEX [item_ident] ON [phpbb_notifications]([item_type], [item_id]) ON [PRIMARY]
|
CREATE INDEX [item_ident] ON [phpbb_notifications]([notification_type_id], [item_id]) ON [PRIMARY]
|
||||||
GO
|
GO
|
||||||
|
|
||||||
CREATE INDEX [user] ON [phpbb_notifications]([user_id], [notification_read]) ON [PRIMARY]
|
CREATE INDEX [user] ON [phpbb_notifications]([user_id], [notification_read]) ON [PRIMARY]
|
||||||
|
@ -1588,7 +1591,7 @@ GO
|
||||||
Table: 'phpbb_user_notifications'
|
Table: 'phpbb_user_notifications'
|
||||||
*/
|
*/
|
||||||
CREATE TABLE [phpbb_user_notifications] (
|
CREATE TABLE [phpbb_user_notifications] (
|
||||||
[item_type] [varchar] (255) DEFAULT ('') NOT NULL ,
|
[notification_type_id] [int] DEFAULT (0) NOT NULL ,
|
||||||
[item_id] [int] DEFAULT (0) NOT NULL ,
|
[item_id] [int] DEFAULT (0) NOT NULL ,
|
||||||
[user_id] [int] DEFAULT (0) NOT NULL ,
|
[user_id] [int] DEFAULT (0) NOT NULL ,
|
||||||
[method] [varchar] (255) DEFAULT ('') NOT NULL ,
|
[method] [varchar] (255) DEFAULT ('') NOT NULL ,
|
||||||
|
|
|
@ -452,16 +452,18 @@ CREATE TABLE phpbb_modules (
|
||||||
|
|
||||||
# Table: 'phpbb_notification_types'
|
# Table: 'phpbb_notification_types'
|
||||||
CREATE TABLE phpbb_notification_types (
|
CREATE TABLE phpbb_notification_types (
|
||||||
notification_type varbinary(255) DEFAULT '' NOT NULL,
|
notification_type_id smallint(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
notification_type_name varbinary(255) DEFAULT '' NOT NULL,
|
||||||
notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
|
notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
|
||||||
PRIMARY KEY (notification_type, notification_type_enabled)
|
PRIMARY KEY (notification_type_id),
|
||||||
|
UNIQUE type (notification_type_name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
# Table: 'phpbb_notifications'
|
# Table: 'phpbb_notifications'
|
||||||
CREATE TABLE phpbb_notifications (
|
CREATE TABLE phpbb_notifications (
|
||||||
notification_id mediumint(8) UNSIGNED NOT NULL auto_increment,
|
notification_id int(10) UNSIGNED NOT NULL auto_increment,
|
||||||
item_type varbinary(255) DEFAULT '' NOT NULL,
|
notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
|
@ -469,7 +471,7 @@ CREATE TABLE phpbb_notifications (
|
||||||
notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL,
|
notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL,
|
||||||
notification_data blob NOT NULL,
|
notification_data blob NOT NULL,
|
||||||
PRIMARY KEY (notification_id),
|
PRIMARY KEY (notification_id),
|
||||||
KEY item_ident (item_type, item_id),
|
KEY item_ident (notification_type_id, item_id),
|
||||||
KEY user (user_id, notification_read)
|
KEY user (user_id, notification_read)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -911,7 +913,7 @@ CREATE TABLE phpbb_topics_watch (
|
||||||
|
|
||||||
# Table: 'phpbb_user_notifications'
|
# Table: 'phpbb_user_notifications'
|
||||||
CREATE TABLE phpbb_user_notifications (
|
CREATE TABLE phpbb_user_notifications (
|
||||||
item_type varbinary(255) DEFAULT '' NOT NULL,
|
notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
method varbinary(255) DEFAULT '' NOT NULL,
|
method varbinary(255) DEFAULT '' NOT NULL,
|
||||||
|
|
|
@ -452,16 +452,18 @@ CREATE TABLE phpbb_modules (
|
||||||
|
|
||||||
# Table: 'phpbb_notification_types'
|
# Table: 'phpbb_notification_types'
|
||||||
CREATE TABLE phpbb_notification_types (
|
CREATE TABLE phpbb_notification_types (
|
||||||
notification_type varchar(255) DEFAULT '' NOT NULL,
|
notification_type_id smallint(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
notification_type_name varchar(255) DEFAULT '' NOT NULL,
|
||||||
notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
|
notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
|
||||||
PRIMARY KEY (notification_type, notification_type_enabled)
|
PRIMARY KEY (notification_type_id),
|
||||||
|
UNIQUE type (notification_type_name)
|
||||||
) CHARACTER SET `utf8` COLLATE `utf8_bin`;
|
) CHARACTER SET `utf8` COLLATE `utf8_bin`;
|
||||||
|
|
||||||
|
|
||||||
# Table: 'phpbb_notifications'
|
# Table: 'phpbb_notifications'
|
||||||
CREATE TABLE phpbb_notifications (
|
CREATE TABLE phpbb_notifications (
|
||||||
notification_id mediumint(8) UNSIGNED NOT NULL auto_increment,
|
notification_id int(10) UNSIGNED NOT NULL auto_increment,
|
||||||
item_type varchar(255) DEFAULT '' NOT NULL,
|
notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
|
@ -469,7 +471,7 @@ CREATE TABLE phpbb_notifications (
|
||||||
notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL,
|
notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL,
|
||||||
notification_data text NOT NULL,
|
notification_data text NOT NULL,
|
||||||
PRIMARY KEY (notification_id),
|
PRIMARY KEY (notification_id),
|
||||||
KEY item_ident (item_type, item_id),
|
KEY item_ident (notification_type_id, item_id),
|
||||||
KEY user (user_id, notification_read)
|
KEY user (user_id, notification_read)
|
||||||
) CHARACTER SET `utf8` COLLATE `utf8_bin`;
|
) CHARACTER SET `utf8` COLLATE `utf8_bin`;
|
||||||
|
|
||||||
|
@ -911,7 +913,7 @@ CREATE TABLE phpbb_topics_watch (
|
||||||
|
|
||||||
# Table: 'phpbb_user_notifications'
|
# Table: 'phpbb_user_notifications'
|
||||||
CREATE TABLE phpbb_user_notifications (
|
CREATE TABLE phpbb_user_notifications (
|
||||||
item_type varchar(255) DEFAULT '' NOT NULL,
|
notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
method varchar(255) DEFAULT '' NOT NULL,
|
method varchar(255) DEFAULT '' NOT NULL,
|
||||||
|
|
|
@ -870,19 +870,37 @@ END;
|
||||||
Table: 'phpbb_notification_types'
|
Table: 'phpbb_notification_types'
|
||||||
*/
|
*/
|
||||||
CREATE TABLE phpbb_notification_types (
|
CREATE TABLE phpbb_notification_types (
|
||||||
notification_type varchar2(255) DEFAULT '' ,
|
notification_type_id number(4) NOT NULL,
|
||||||
|
notification_type_name varchar2(255) DEFAULT '' ,
|
||||||
notification_type_enabled number(1) DEFAULT '1' NOT NULL,
|
notification_type_enabled number(1) DEFAULT '1' NOT NULL,
|
||||||
CONSTRAINT pk_phpbb_notification_types PRIMARY KEY (notification_type, notification_type_enabled)
|
CONSTRAINT pk_phpbb_notification_types PRIMARY KEY (notification_type_id),
|
||||||
|
CONSTRAINT u_phpbb_type UNIQUE (notification_type_name)
|
||||||
)
|
)
|
||||||
/
|
/
|
||||||
|
|
||||||
|
|
||||||
|
CREATE SEQUENCE phpbb_notification_types_seq
|
||||||
|
/
|
||||||
|
|
||||||
|
CREATE OR REPLACE TRIGGER t_phpbb_notification_types
|
||||||
|
BEFORE INSERT ON phpbb_notification_types
|
||||||
|
FOR EACH ROW WHEN (
|
||||||
|
new.notification_type_id IS NULL OR new.notification_type_id = 0
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
SELECT phpbb_notification_types_seq.nextval
|
||||||
|
INTO :new.notification_type_id
|
||||||
|
FROM dual;
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Table: 'phpbb_notifications'
|
Table: 'phpbb_notifications'
|
||||||
*/
|
*/
|
||||||
CREATE TABLE phpbb_notifications (
|
CREATE TABLE phpbb_notifications (
|
||||||
notification_id number(8) NOT NULL,
|
notification_id number(10) NOT NULL,
|
||||||
item_type varchar2(255) DEFAULT '' ,
|
notification_type_id number(4) DEFAULT '0' NOT NULL,
|
||||||
item_id number(8) DEFAULT '0' NOT NULL,
|
item_id number(8) DEFAULT '0' NOT NULL,
|
||||||
item_parent_id number(8) DEFAULT '0' NOT NULL,
|
item_parent_id number(8) DEFAULT '0' NOT NULL,
|
||||||
user_id number(8) DEFAULT '0' NOT NULL,
|
user_id number(8) DEFAULT '0' NOT NULL,
|
||||||
|
@ -893,7 +911,7 @@ CREATE TABLE phpbb_notifications (
|
||||||
)
|
)
|
||||||
/
|
/
|
||||||
|
|
||||||
CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id)
|
CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (notification_type_id, item_id)
|
||||||
/
|
/
|
||||||
CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read)
|
CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read)
|
||||||
/
|
/
|
||||||
|
@ -1702,7 +1720,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status
|
||||||
Table: 'phpbb_user_notifications'
|
Table: 'phpbb_user_notifications'
|
||||||
*/
|
*/
|
||||||
CREATE TABLE phpbb_user_notifications (
|
CREATE TABLE phpbb_user_notifications (
|
||||||
item_type varchar2(255) DEFAULT '' ,
|
notification_type_id number(4) DEFAULT '0' NOT NULL,
|
||||||
item_id number(8) DEFAULT '0' NOT NULL,
|
item_id number(8) DEFAULT '0' NOT NULL,
|
||||||
user_id number(8) DEFAULT '0' NOT NULL,
|
user_id number(8) DEFAULT '0' NOT NULL,
|
||||||
method varchar2(255) DEFAULT '' ,
|
method varchar2(255) DEFAULT '' ,
|
||||||
|
|
|
@ -623,12 +623,16 @@ CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id
|
||||||
/*
|
/*
|
||||||
Table: 'phpbb_notification_types'
|
Table: 'phpbb_notification_types'
|
||||||
*/
|
*/
|
||||||
|
CREATE SEQUENCE phpbb_notification_types_seq;
|
||||||
|
|
||||||
CREATE TABLE phpbb_notification_types (
|
CREATE TABLE phpbb_notification_types (
|
||||||
notification_type varchar(255) DEFAULT '' NOT NULL,
|
notification_type_id INT2 DEFAULT nextval('phpbb_notification_types_seq'),
|
||||||
|
notification_type_name varchar(255) DEFAULT '' NOT NULL,
|
||||||
notification_type_enabled INT2 DEFAULT '1' NOT NULL CHECK (notification_type_enabled >= 0),
|
notification_type_enabled INT2 DEFAULT '1' NOT NULL CHECK (notification_type_enabled >= 0),
|
||||||
PRIMARY KEY (notification_type, notification_type_enabled)
|
PRIMARY KEY (notification_type_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX phpbb_notification_types_type ON phpbb_notification_types (notification_type_name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Table: 'phpbb_notifications'
|
Table: 'phpbb_notifications'
|
||||||
|
@ -637,7 +641,7 @@ CREATE SEQUENCE phpbb_notifications_seq;
|
||||||
|
|
||||||
CREATE TABLE phpbb_notifications (
|
CREATE TABLE phpbb_notifications (
|
||||||
notification_id INT4 DEFAULT nextval('phpbb_notifications_seq'),
|
notification_id INT4 DEFAULT nextval('phpbb_notifications_seq'),
|
||||||
item_type varchar(255) DEFAULT '' NOT NULL,
|
notification_type_id INT2 DEFAULT '0' NOT NULL CHECK (notification_type_id >= 0),
|
||||||
item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0),
|
item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0),
|
||||||
item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0),
|
item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0),
|
||||||
user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0),
|
user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0),
|
||||||
|
@ -647,7 +651,7 @@ CREATE TABLE phpbb_notifications (
|
||||||
PRIMARY KEY (notification_id)
|
PRIMARY KEY (notification_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id);
|
CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (notification_type_id, item_id);
|
||||||
CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read);
|
CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1171,7 +1175,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status
|
||||||
Table: 'phpbb_user_notifications'
|
Table: 'phpbb_user_notifications'
|
||||||
*/
|
*/
|
||||||
CREATE TABLE phpbb_user_notifications (
|
CREATE TABLE phpbb_user_notifications (
|
||||||
item_type varchar(255) DEFAULT '' NOT NULL,
|
notification_type_id INT2 DEFAULT '0' NOT NULL CHECK (notification_type_id >= 0),
|
||||||
item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0),
|
item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0),
|
||||||
user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0),
|
user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0),
|
||||||
method varchar(255) DEFAULT '' NOT NULL,
|
method varchar(255) DEFAULT '' NOT NULL,
|
||||||
|
|
|
@ -439,16 +439,17 @@ CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id
|
||||||
|
|
||||||
# Table: 'phpbb_notification_types'
|
# Table: 'phpbb_notification_types'
|
||||||
CREATE TABLE phpbb_notification_types (
|
CREATE TABLE phpbb_notification_types (
|
||||||
notification_type varchar(255) NOT NULL DEFAULT '',
|
notification_type_id INTEGER PRIMARY KEY NOT NULL ,
|
||||||
notification_type_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1',
|
notification_type_name varchar(255) NOT NULL DEFAULT '',
|
||||||
PRIMARY KEY (notification_type, notification_type_enabled)
|
notification_type_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX phpbb_notification_types_type ON phpbb_notification_types (notification_type_name);
|
||||||
|
|
||||||
# Table: 'phpbb_notifications'
|
# Table: 'phpbb_notifications'
|
||||||
CREATE TABLE phpbb_notifications (
|
CREATE TABLE phpbb_notifications (
|
||||||
notification_id INTEGER PRIMARY KEY NOT NULL ,
|
notification_id INTEGER PRIMARY KEY NOT NULL ,
|
||||||
item_type varchar(255) NOT NULL DEFAULT '',
|
notification_type_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
||||||
item_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
item_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
||||||
item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
||||||
user_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
user_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
||||||
|
@ -457,7 +458,7 @@ CREATE TABLE phpbb_notifications (
|
||||||
notification_data text(65535) NOT NULL DEFAULT ''
|
notification_data text(65535) NOT NULL DEFAULT ''
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id);
|
CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (notification_type_id, item_id);
|
||||||
CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read);
|
CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read);
|
||||||
|
|
||||||
# Table: 'phpbb_poll_options'
|
# Table: 'phpbb_poll_options'
|
||||||
|
@ -883,7 +884,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status
|
||||||
|
|
||||||
# Table: 'phpbb_user_notifications'
|
# Table: 'phpbb_user_notifications'
|
||||||
CREATE TABLE phpbb_user_notifications (
|
CREATE TABLE phpbb_user_notifications (
|
||||||
item_type varchar(255) NOT NULL DEFAULT '',
|
notification_type_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
||||||
item_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
item_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
||||||
user_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
user_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
|
||||||
method varchar(255) NOT NULL DEFAULT '',
|
method varchar(255) NOT NULL DEFAULT '',
|
||||||
|
|
Loading…
Add table
Reference in a new issue