CreateAccessLogTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 15 1
A down() 0 10 1
1
<?php
2
3
namespace VojtaSvoboda\UserAccessLog\Updates;
4
5
use Schema;
6
use Illuminate\Support\Facades\DB;
7
use October\Rain\Database\Updates\Migration;
8
9
class CreateAccessLogTable extends Migration
10
{
11
12
	public function up()
13
	{
14
		Schema::create('user_access_log', function($table)
15
		{
16
			$table->engine = 'InnoDB';
17
			$table->increments('id');
18
19
			$table->integer('user_id')->unsigned()->nullable();
20
			$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
21
22
			$table->string('ip_address')->nullable();
23
24
			$table->timestamps();
25
		});
26
	}
27
28
	public function down()
29
	{
30
		DB::statement("SET foreign_key_checks = 0");
31
		Schema::table('user_access_log', function($table)
32
		{
33
			$table->dropForeign('user_access_log_user_id_foreign');
34
		});
35
		Schema::dropIfExists('user_access_log');
36
		DB::statement("SET foreign_key_checks = 1");
37
	}
38
39
}
40