Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
41 / 41
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
phpbb_dbal_migration_schema_index
100.00% covered (success)
100.00%
41 / 41
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 update_schema
100.00% covered (success)
100.00%
35 / 35
100.00% covered (success)
100.00%
1 / 1
1
 revert_schema
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14class phpbb_dbal_migration_schema_index extends \phpbb\db\migration\migration
15{
16    function update_schema()
17    {
18        return [
19            'add_tables' => [
20                $this->table_prefix . 'foobar1' => [
21                    'COLUMNS' => [
22                        'user_id' => ['UINT', 0],
23                        'username' => ['VCHAR:50', 0],
24                    ],
25                    'KEYS'    => [
26                        'tstidx_user_id' => ['UNIQUE', 'user_id'],
27                        'tstidx_username' => ['INDEX', 'username'],
28                    ],
29                ],
30                $this->table_prefix . 'foobar2' => [
31                    'COLUMNS' => [
32                        'ban_userid'        => ['ULINT', 0],
33                        'ban_ip'            => ['VCHAR:40', ''],
34                        'ban_reason'        => ['VCHAR:100', ''],
35                    ],
36                    'KEYS'    => [
37                        'tstidx_ban_userid' => ['UNIQUE', 'ban_userid'],
38                        'tstidxban_data' => ['INDEX', ['ban_ip', 'ban_reason']],
39                    ],
40                ],
41            ],
42
43            'rename_index' => [
44                $this->table_prefix . 'foobar1' => [
45                    'tstidx_user_id' => 'fbr1_user_id',
46                    'tstidx_username' => 'fbr1_username',
47                ],
48                $this->table_prefix . 'foobar2' => [
49                    'tstidx_ban_userid' => 'fbr2_ban_userid',
50                    'tstidxban_data' => 'fbr2_ban_data',
51                ],
52            ],
53        ];
54    }
55
56    function revert_schema()
57    {
58        return [
59            'drop_tables'    => [
60                $this->table_prefix . 'foobar1',
61                $this->table_prefix . 'foobar2',
62            ],
63        ];
64    }
65}