Completed
Push — master ( a54cfa...dab35b )
by Nur
09:38
created

CreateMasterStatesTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 18
dl 0
loc 38
c 1
b 0
f 1
rs 10
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateMasterStatesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('tm_states', function (Blueprint $table) {
17
            $table->bigIncrements('id');
18
            $table->unsignedBigInteger('country_id');
19
            $table->string('name', 255);
20
            $table->string('region', 255)->nullable();
21
            $table->string('iso_3166_2', 2)->nullable();
22
            $table->string('region_code', 10)->nullable();
23
            $table->string('calling_code', 5)->nullable();
24
            $table->string('latitude')->nullable();
25
            $table->string('longitude')->nullable();
26
            $table->boolean('active')->default(1);
27
            $table->timestamps();
28
        });
29
30
        Schema::table('tm_states', function (Blueprint $table) {
31
            $table->foreign('country_id')
32
                ->references('id')->on('tm_countries')
33
                ->onDelete('cascade');
34
        });
35
    }
36
37
    /**
38
     * Reverse the migrations.
39
     *
40
     * @return void
41
     */
42
    public function down()
43
    {
44
        Schema::dropIfExists('tm_states');
45
    }
46
}
47