Passed
Push — master ( c36ed8...8867a0 )
by Quentin
13:25 queued 05:48
created

CreateTwillUsersTables   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
c 0
b 0
f 0
dl 0
loc 44
rs 10
wmc 4
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateTwillUsersTables extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        $twillUsersTable = config('twill.users_table', 'twill_users');
17
18
        if (!Schema::hasTable($twillUsersTable)) {
19
            Schema::create($twillUsersTable, function (Blueprint $table) {
20
                createDefaultTableFields($table);
21
                $table->string('name');
22
                $table->string('email')->unique();
23
                $table->string('password', 60)->nullable()->default(null);
24
                $table->string('role', 100);
25
                $table->string('title', 255)->nullable();
26
                $table->text('description')->nullable();
27
                $table->rememberToken();
28
            });
29
        }
30
31
        $twillPasswordResetsTable = config('twill.password_resets_table', 'twill_password_resets');
32
33
        if (!Schema::hasTable($twillPasswordResetsTable)) {
34
            Schema::create($twillPasswordResetsTable, function (Blueprint $table) {
35
                $table->string('email')->index();
36
                $table->string('token')->index();
37
                $table->timestamp('created_at')->nullable();
38
            });
39
        }
40
    }
41
42
    /**
43
     * Reverse the migrations.
44
     *
45
     * @return void
46
     */
47
    public function down()
48
    {
49
        Schema::dropIfExists(config('twill.password_resets_table', 'twill_password_resets'));
50
        Schema::dropIfExists(config('twill.users_table', 'twill_users'));
51
    }
52
}
53