CreateTranslationsTable::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 7
Bugs 4 Features 0
Metric Value
eloc 1
c 7
b 4
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateTranslationsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('translations', function (Blueprint $table) {
17
            $table->string('key');
18
            $table->text('value');
19
            $table->bigInteger('translatable_id')->unsigned();
20
            $table->string('translatable_type');
21
            $table->string('locale');
22
        });
23
        
24
        // sqlite does not like this...
25
        if (app()->environment() !== 'testing') {
0 ignored issues
show
introduced by
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        if (app()->/** @scrutinizer ignore-call */ environment() !== 'testing') {
Loading history...
26
            \DB::statement('ALTER TABLE `translations` ADD FULLTEXT fulltext_index (`value`)');
27
            \DB::statement('ALTER TABLE `translations` ADD INDEX `type_local_key_id`(`key`, `translatable_id`, `translatable_type`, `locale`);');
28
        }
29
    }
30
    
31
    /**
32
     * Reverse the migrations.
33
     *
34
     * @return void
35
     */
36
    public function down()
37
    {
38
        Schema::dropIfExists('translations');
39
    }
40
}
41