mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-27 04:18:55 +00:00
Compare commits
3 commits
5e2dcf9d8f
...
45a69eca14
Author | SHA1 | Date | |
---|---|---|---|
|
45a69eca14 | ||
|
84d195ac21 | ||
|
78dcb0c862 |
3 changed files with 98 additions and 1 deletions
|
@ -15,7 +15,7 @@ namespace phpbb\db\migration\data\v400;
|
||||||
|
|
||||||
use phpbb\db\migration\migration;
|
use phpbb\db\migration\migration;
|
||||||
|
|
||||||
class rename_auth_role_id_index extends migration
|
class rename_duplicated_index_names extends migration
|
||||||
{
|
{
|
||||||
public static function depends_on()
|
public static function depends_on()
|
||||||
{
|
{
|
||||||
|
@ -40,11 +40,15 @@ class rename_auth_role_id_index extends migration
|
||||||
'poster_id' => 'attchmnts_poster_id',
|
'poster_id' => 'attchmnts_poster_id',
|
||||||
'topic_id' => 'attchmnts_topic_id',
|
'topic_id' => 'attchmnts_topic_id',
|
||||||
],
|
],
|
||||||
|
$this->table_prefix . 'bbcodes' => [
|
||||||
|
'display_on_post' => 'bbcds_display_on_post',
|
||||||
|
],
|
||||||
$this->table_prefix . 'forums' => [
|
$this->table_prefix . 'forums' => [
|
||||||
'left_right_id' => 'frms_left_right_id',
|
'left_right_id' => 'frms_left_right_id',
|
||||||
],
|
],
|
||||||
$this->table_prefix . 'forums_watch' => [
|
$this->table_prefix . 'forums_watch' => [
|
||||||
'forum_id' => 'frmswtch_forum_id',
|
'forum_id' => 'frmswtch_forum_id',
|
||||||
|
'notify_stat' => 'frmswtch_notify_stat',
|
||||||
'user_id' => 'frmswtch_user_id',
|
'user_id' => 'frmswtch_user_id',
|
||||||
],
|
],
|
||||||
$this->table_prefix . 'log' => [
|
$this->table_prefix . 'log' => [
|
||||||
|
@ -98,6 +102,9 @@ class rename_auth_role_id_index extends migration
|
||||||
$this->table_prefix . 'search_wordmatch' => [
|
$this->table_prefix . 'search_wordmatch' => [
|
||||||
'post_id' => 'wrdmtch_post_id',
|
'post_id' => 'wrdmtch_post_id',
|
||||||
],
|
],
|
||||||
|
$this->table_prefix . 'smilies' => [
|
||||||
|
'display_on_post' => 'smls_display_on_post',
|
||||||
|
],
|
||||||
$this->table_prefix . 'topics' => [
|
$this->table_prefix . 'topics' => [
|
||||||
'forum_id' => 'tpcs_forum_id',
|
'forum_id' => 'tpcs_forum_id',
|
||||||
],
|
],
|
||||||
|
@ -107,6 +114,7 @@ class rename_auth_role_id_index extends migration
|
||||||
],
|
],
|
||||||
$this->table_prefix . 'topics_watch' => [
|
$this->table_prefix . 'topics_watch' => [
|
||||||
'topic_id' => 'tpcswtch_topic_id',
|
'topic_id' => 'tpcswtch_topic_id',
|
||||||
|
'notify_stat' => 'tpcswtch_notify_stat',
|
||||||
'user_id' => 'tpcswtch_user_id',
|
'user_id' => 'tpcswtch_user_id',
|
||||||
],
|
],
|
||||||
$this->table_prefix . 'user_group' => [
|
$this->table_prefix . 'user_group' => [
|
65
tests/dbal/migration/schema_index.php
Normal file
65
tests/dbal/migration/schema_index.php
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class phpbb_dbal_migration_schema_index extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
function update_schema()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'add_tables' => [
|
||||||
|
$this->table_prefix . 'foobar1' => [
|
||||||
|
'COLUMNS' => [
|
||||||
|
'user_id' => ['UINT', 0],
|
||||||
|
'username' => ['VCHAR:50', 0],
|
||||||
|
],
|
||||||
|
'KEYS' => [
|
||||||
|
'tstidx_user_id' => ['UNIQUE', 'user_id'],
|
||||||
|
'tstidx_username' => ['INDEX', 'username'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
$this->table_prefix . 'foobar2' => [
|
||||||
|
'COLUMNS' => [
|
||||||
|
'ban_userid' => ['ULINT', 0],
|
||||||
|
'ban_ip' => ['VCHAR:40', ''],
|
||||||
|
'ban_reason' => ['VCHAR:100', ''],
|
||||||
|
],
|
||||||
|
'KEYS' => [
|
||||||
|
'tstidx_ban_userid' => ['UNIQUE', 'ban_userid'],
|
||||||
|
'tstidxban_data' => ['INDEX', ['ban_ip', 'ban_reason']],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'rename_index' => [
|
||||||
|
$this->table_prefix . 'foobar1' => [
|
||||||
|
'tstidx_user_id' => 'fbr1_user_id',
|
||||||
|
'tstidx_username' => 'fbr1_username',
|
||||||
|
],
|
||||||
|
$this->table_prefix . 'foobar2' => [
|
||||||
|
'tstidx_ban_userid' => 'fbr2_ban_userid',
|
||||||
|
'tstidxban_data' => 'fbr2_ban_data',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function revert_schema()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'drop_tables' => [
|
||||||
|
$this->table_prefix . 'foobar1',
|
||||||
|
$this->table_prefix . 'foobar2',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ require_once __DIR__ . '/migration/revert_table_with_dependency.php';
|
||||||
require_once __DIR__ . '/migration/fail.php';
|
require_once __DIR__ . '/migration/fail.php';
|
||||||
require_once __DIR__ . '/migration/installed.php';
|
require_once __DIR__ . '/migration/installed.php';
|
||||||
require_once __DIR__ . '/migration/schema.php';
|
require_once __DIR__ . '/migration/schema.php';
|
||||||
|
require_once __DIR__ . '/migration/schema_index.php';
|
||||||
|
|
||||||
class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||||
{
|
{
|
||||||
|
@ -416,4 +417,27 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||||
$this->assertFalse($this->db_tools->sql_column_exists('phpbb_config', 'test_column1'));
|
$this->assertFalse($this->db_tools->sql_column_exists('phpbb_config', 'test_column1'));
|
||||||
$this->assertFalse($this->db_tools->sql_table_exists('phpbb_foobar'));
|
$this->assertFalse($this->db_tools->sql_table_exists('phpbb_foobar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_rename_index()
|
||||||
|
{
|
||||||
|
$this->migrator->set_migrations(array('phpbb_dbal_migration_schema_index'));
|
||||||
|
|
||||||
|
while (!$this->migrator->finished())
|
||||||
|
{
|
||||||
|
$this->migrator->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertTrue($this->db_tools->sql_unique_index_exists('phpbb_foobar1', 'fbr1_user_id'));
|
||||||
|
$this->assertTrue($this->db_tools->sql_index_exists('phpbb_foobar1', 'fbr1_username'));
|
||||||
|
$this->assertTrue($this->db_tools->sql_unique_index_exists('phpbb_foobar2', 'fbr2_ban_userid'));
|
||||||
|
$this->assertTrue($this->db_tools->sql_index_exists('phpbb_foobar2', 'fbr2_ban_data'));
|
||||||
|
|
||||||
|
while ($this->migrator->migration_state('phpbb_dbal_migration_schema_index'))
|
||||||
|
{
|
||||||
|
$this->migrator->revert('phpbb_dbal_migration_schema_index');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertFalse($this->db_tools->sql_table_exists('phpbb_foobar1'));
|
||||||
|
$this->assertFalse($this->db_tools->sql_table_exists('phpbb_foobar2'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue