Passed
Push — v3 ( a19b86...5f7589 )
by Andrew
25:32 queued 05:19
created

m200109_144310_add_redirectSrcUrl_index::safeUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace nystudio107\retour\migrations;
4
5
use Craft;
6
use craft\db\Migration;
7
8
/**
9
 * m200109_144310_add_redirectSrcUrl_index migration.
10
 */
11
class m200109_144310_add_redirectSrcUrl_index extends Migration
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public function safeUp()
17
    {
18
        $this->createIndexes();
19
    }
20
21
    /**
22
     * @inheritdoc
23
     */
24
    public function safeDown()
25
    {
26
        echo "m200109_144310_add_redirectSrcUrl_index cannot be reverted.\n";
27
        return false;
28
    }
29
30
    /**
31
     * @return void
32
     */
33
    protected function createIndexes()
34
    {
35
        $this->createIndex(
36
            $this->db->getIndexName(
37
                '{{%retour_static_redirects}}',
38
                'redirectSrcUrl',
39
                false
40
            ),
41
            '{{%retour_static_redirects}}',
42
            'redirectSrcUrl',
43
            false
44
        );
45
46
        $this->createIndex(
47
            $this->db->getIndexName(
48
                '{{%retour_redirects}}',
49
                'redirectSrcUrl',
50
                false
51
            ),
52
            '{{%retour_redirects}}',
53
            'redirectSrcUrl',
54
            false
55
        );
56
57
        $this->createIndex(
58
            $this->db->getIndexName(
59
                '{{%retour_stats}}',
60
                'redirectSrcUrl',
61
                false
62
            ),
63
            '{{%retour_stats}}',
64
            'redirectSrcUrl',
65
            false
66
        );
67
    }
68
}
69