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

CreateMasterCitiesTable::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
dl 0
loc 16
c 1
b 0
f 1
rs 9.8666
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 CreateMasterCitiesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('tm_cities', function (Blueprint $table) {
17
            $table->bigIncrements('id');
18
            $table->string('name');
19
            $table->string('postal_code')->nullable();
20
            $table->string('latitude')->nullable();
21
            $table->string('longitude')->nullable();
22
            $table->unsignedBigInteger('state_id');
23
            $table->timestamps();
24
        });
25
26
        Schema::table('tm_cities', function (Blueprint $table) {
27
            $table->foreign('state_id')
28
                ->references('id')->on('tm_states')
29
                ->onDelete('cascade');
30
        });
31
    }
32
33
    /**
34
     * Reverse the migrations.
35
     *
36
     * @return void
37
     */
38
    public function down()
39
    {
40
        Schema::dropIfExists('tm_cities');
41
    }
42
}
43