CreateContactsTables::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
use Illuminate\Database\Schema\Blueprint;
3
use Illuminate\Database\Migrations\Migration;
4
5
class CreateContactsTables extends Migration
6
{
7
8
    /**
9
     * Run the migrations.
10
     *
11
     * @return void
12
     */
13
    public function up()
14
    {
15
        
16
        Schema::create(
17
            'emails', function (Blueprint $table) {
18
                $table->engine = 'InnoDB';
19
                $table->string('email')->unique();
20
                $table->primary('email');
21
                $table->string('address', 255)->nullable();
22
                $table->string('domain')->nullable();
23
                $table->integer('integration_id')->nullable();
24
                $table->unique(['address', 'domain', 'integration_id']);
25
                $table->timestamps();
26
                $table->softDeletes();
27
            }
28
        );
29
        
30
        Schema::create(
31 View Code Duplication
            'emailables', function (Blueprint $table) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
                $table->engine = 'InnoDB';
33
                $table->string('emailable_id');
34
                $table->string('emailable_type', 255);
35
                $table->string('email_email');
36
                $table->foreign('email_email')->references('email')->on('emails');
37
            
38
                $table->timestamps();
39
                $table->softDeletes();
40
            }
41
        );
42
        
43
        Schema::create(
44
            'phones', function (Blueprint $table) {
45
                $table->engine = 'InnoDB';
46
                $table->increments('id')->unsigned();
47
                $table->string('country', 255)->default('55')->nullable();
48
                $table->string('state', 255)->default('21')->nullable();
49
                $table->string('number')->nullable();
50
                $table->integer('whatsapp')->nullable();
51
                $table->timestamps();
52
                $table->softDeletes();
53
            }
54
        );
55
        
56
        Schema::create(
57
            'phoneables', function (Blueprint $table) {
58
                $table->engine = 'InnoDB';
59
                $table->integer('phone_id')->unsigned();
60
                $table->string('phoneable_id');
61
                $table->string('phoneable_type', 255);
62
                $table->timestamps();
63
                $table->softDeletes();
64
            }
65
        );
66
        
67
        
68
69
    }
70
71
    /**
72
     * Reverse the migrations.
73
     *
74
     * @return void
75
     */
76
    public function down()
77
    {
78
79
80
81
        Schema::dropIfExists('phoneables');
82
        Schema::dropIfExists('phones');
83
        Schema::dropIfExists('emailables');
84
        Schema::dropIfExists('emails');
85
    }
86
87
}
88