mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/9687] Update ban migrations and clean up code
PHPBB3-9687
This commit is contained in:
parent
d4a4dd453a
commit
d99968a800
2 changed files with 72 additions and 70 deletions
|
@ -11,59 +11,61 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
namespace phpbb\db\migration\data\v400;
|
||||
|
||||
class ban_table_p1 extends \phpbb\db\migration\migration
|
||||
use phpbb\db\migration\migration;
|
||||
|
||||
class ban_table_p1 extends migration
|
||||
{
|
||||
static public function depends_on()
|
||||
static public function depends_on(): array
|
||||
{
|
||||
return array('\phpbb\db\migration\data\v320\default_data_type_ids');
|
||||
return ['\phpbb\db\migration\data\v320\default_data_type_ids'];
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
public function update_schema(): array
|
||||
{
|
||||
return array(
|
||||
'add_tables' => array(
|
||||
$this->table_prefix . 'bans' => array(
|
||||
'COLUMNS' => array(
|
||||
'ban_id' => array('ULINT', null, 'auto_increment'),
|
||||
'ban_mode' => array('VCHAR', ''),
|
||||
'ban_item' => array('STEXT_UNI', ''),
|
||||
'ban_start' => array('TIMESTAMP', 0),
|
||||
'ban_end' => array('TIMESTAMP', 0),
|
||||
'ban_reason' => array('VCHAR_UNI', ''),
|
||||
'ban_reason_display' => array('VCHAR_UNI', ''),
|
||||
),
|
||||
return [
|
||||
'add_tables' => [
|
||||
$this->table_prefix . 'bans' => [
|
||||
'COLUMNS' => [
|
||||
'ban_id' => ['ULINT', null, 'auto_increment'],
|
||||
'ban_mode' => ['VCHAR', ''],
|
||||
'ban_item' => ['STEXT_UNI', ''],
|
||||
'ban_start' => ['TIMESTAMP', 0],
|
||||
'ban_end' => ['TIMESTAMP', 0],
|
||||
'ban_reason' => ['VCHAR_UNI', ''],
|
||||
'ban_reason_display' => ['VCHAR_UNI', ''],
|
||||
],
|
||||
'PRIMARY_KEY' => 'ban_id',
|
||||
'KEYS' => array(
|
||||
'ban_end' => array('INDEX', 'ban_end'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
'KEYS' => [
|
||||
'ban_end' => ['INDEX', 'ban_end'],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_schema()
|
||||
public function revert_schema(): array
|
||||
{
|
||||
return array(
|
||||
'drop_tables' => array(
|
||||
return [
|
||||
'drop_tables' => [
|
||||
$this->table_prefix . 'bans',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
public function update_data(): array
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'old_to_new'))),
|
||||
);
|
||||
return [
|
||||
['custom', [[$this, 'old_to_new']]],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_data()
|
||||
public function revert_data(): array
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'new_to_old'))),
|
||||
);
|
||||
return [
|
||||
['custom', [[$this, 'new_to_old']]],
|
||||
];
|
||||
}
|
||||
|
||||
public function old_to_new($start)
|
||||
|
@ -73,7 +75,7 @@ class ban_table_p1 extends \phpbb\db\migration\migration
|
|||
$processed_rows = 0;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . $this->table_prefix . "banlist";
|
||||
FROM ' . $this->table_prefix . 'banlist';
|
||||
$result = $this->db->sql_query_limit($sql, $limit, $start);
|
||||
|
||||
$bans = [];
|
||||
|
@ -139,7 +141,7 @@ class ban_table_p1 extends \phpbb\db\migration\migration
|
|||
$processed_rows = 0;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . $this->table_prefix . "bans";
|
||||
FROM ' . $this->table_prefix . 'bans';
|
||||
$result = $this->db->sql_query_limit($sql, $limit, $start);
|
||||
|
||||
$bans = [];
|
||||
|
|
|
@ -11,49 +11,49 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v330;
|
||||
namespace phpbb\db\migration\data\v400;
|
||||
|
||||
class ban_table_p2 extends \phpbb\db\migration\migration
|
||||
{
|
||||
static public function depends_on()
|
||||
static public function depends_on(): array
|
||||
{
|
||||
return array('\phpbb\db\migration\data\v330\ban_table_p1');
|
||||
return ['\phpbb\db\migration\data\v400\ban_table_p1'];
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
public function update_schema(): array
|
||||
{
|
||||
return array(
|
||||
'drop_tables' => array(
|
||||
return [
|
||||
'drop_tables' => [
|
||||
$this->table_prefix . 'banlist',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_schema()
|
||||
public function revert_schema(): array
|
||||
{
|
||||
return array(
|
||||
'add_tables' => array(
|
||||
$this->table_prefix . 'banlist' => array(
|
||||
'COLUMNS' => array(
|
||||
'ban_id' => array('ULINT', null, 'auto_increment'),
|
||||
'ban_userid' => array('ULINT', 0),
|
||||
'ban_ip' => array('VCHAR:40', ''),
|
||||
'ban_email' => array('VCHAR_UNI:100', ''),
|
||||
'ban_start' => array('TIMESTAMP', 0),
|
||||
'ban_end' => array('TIMESTAMP', 0),
|
||||
'ban_exclude' => array('BOOL', 0),
|
||||
'ban_reason' => array('VCHAR_UNI', ''),
|
||||
'ban_give_reason' => array('VCHAR_UNI', ''),
|
||||
),
|
||||
return [
|
||||
'add_tables' => [
|
||||
$this->table_prefix . 'banlist' => [
|
||||
'COLUMNS' => [
|
||||
'ban_id' => ['ULINT', null, 'auto_increment'],
|
||||
'ban_userid' => ['ULINT', 0],
|
||||
'ban_ip' => ['VCHAR:40', ''],
|
||||
'ban_email' => ['VCHAR_UNI:100', ''],
|
||||
'ban_start' => ['TIMESTAMP', 0],
|
||||
'ban_end' => ['TIMESTAMP', 0],
|
||||
'ban_exclude' => ['BOOL', 0],
|
||||
'ban_reason' => ['VCHAR_UNI', ''],
|
||||
'ban_give_reason' => ['VCHAR_UNI', ''],
|
||||
],
|
||||
'PRIMARY_KEY' => 'ban_id',
|
||||
'KEYS' => array(
|
||||
'ban_end' => array('INDEX', 'ban_end'),
|
||||
'ban_user' => array('INDEX', array('ban_userid', 'ban_exclude')),
|
||||
'ban_email' => array('INDEX', array('ban_email', 'ban_exclude')),
|
||||
'ban_ip' => array('INDEX', array('ban_ip', 'ban_exclude')),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
'KEYS' => [
|
||||
'ban_end' => ['INDEX', 'ban_end'],
|
||||
'ban_user' => ['INDEX', ['ban_userid', 'ban_exclude']],
|
||||
'ban_email' => ['INDEX', ['ban_email', 'ban_exclude']],
|
||||
'ban_ip' => ['INDEX', ['ban_ip', 'ban_exclude']],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue