CreateTranslationsTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 10
Bugs 5 Features 0
Metric Value
wmc 3
eloc 11
c 10
b 5
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 14 2
A down() 0 3 1
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