Completed
Pull Request — develop (#131)
by
unknown
01:18
created

AddAttributeValueIndexes::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
use Illuminate\Support\Facades\Schema;
6
use Illuminate\Database\Schema\Blueprint;
7
use Illuminate\Database\Migrations\Migration;
8
9
class AddAttributeValueIndexes extends Migration
10
{
11
    /**
12
     * Run the migrations.
13
     *
14
     * @return void
15
     */
16
    public function up()
17
    {
18
        Schema::table(config('rinvex.attributes.tables.attribute_boolean_values'), function (Blueprint $table) {
19
            $table->index(['attribute_id', 'entity_id', 'entity_type'], 'attribute_boolean_values_index');
20
            $table->index(['content']);
21
        });
22
        Schema::table(config('rinvex.attributes.tables.attribute_datetime_values'), function (Blueprint $table) {
23
            $table->index(['attribute_id', 'entity_id', 'entity_type'], 'attribute_datetime_values_index');
24
            $table->index(['content']);
25
        });
26
        Schema::table(config('rinvex.attributes.tables.attribute_integer_values'), function (Blueprint $table) {
27
            $table->index(['attribute_id', 'entity_id', 'entity_type'], 'attribute_integer_values_index');
28
            $table->index(['content']);
29
        });
30
        Schema::table(config('rinvex.attributes.tables.attribute_text_values'), function (Blueprint $table) {
31
            $table->index(['attribute_id', 'entity_id', 'entity_type'], 'attribute_text_values_index');
32
        });
33
        Schema::table(config('rinvex.attributes.tables.attribute_varchar_values'), function (Blueprint $table) {
34
            $table->index(['attribute_id', 'entity_id', 'entity_type'], 'attribute_varchar_values_index');
35
            $table->index(['content']);
36
        });
37
    }
38
39
    /**
40
     * Reverse the migrations.
41
     *
42
     * @return void
43
     */
44
    public function down()
45
    {
46
        Schema::table(config('rinvex.attributes.tables.attribute_boolean_values'), function (Blueprint $table) {
47
            $table->dropIndex('attribute_boolean_values_index');
48
            $table->dropIndex(['content']);
49
        });
50
        Schema::table(config('rinvex.attributes.tables.attribute_datetime_values'), function (Blueprint $table) {
51
            $table->dropIndex('attribute_datetime_values_index');
52
            $table->dropIndex(['content']);
53
        });
54
        Schema::table(config('rinvex.attributes.tables.attribute_integer_values'), function (Blueprint $table) {
55
            $table->dropIndex('attribute_integer_values_index');
56
            $table->dropIndex(['content']);
57
        });
58
        Schema::table(config('rinvex.attributes.tables.attribute_text_values'), function (Blueprint $table) {
59
            $table->dropIndex('attribute_text_values_index');
60
        });
61
        Schema::table(config('rinvex.attributes.tables.attribute_varchar_values'), function (Blueprint $table) {
62
            $table->dropIndex('attribute_varchar_values_index');
63
            $table->dropIndex(['content']);
64
        });
65
    }
66
}
67