AddAuditsTable20220323095520::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Platine\Framework\Migration;
6
7
use Platine\Database\Schema\CreateTable;
8
use Platine\Framework\Migration\AbstractMigration;
9
10
class AddAuditsTable20220323095520 extends AbstractMigration
11
{
12
    public function up(): void
13
    {
14
      //Action when migrate up
15
        $this->create('audits', function (CreateTable $table) {
16
            $table->integer('id')
17
                  ->autoincrement()
18
                  ->primary();
19
20
            $table->string('event')
21
                    ->description('The audit event')
22
                    ->index()
23
                    ->notNull();
24
25
            $table->text('detail')
26
                  ->description('The audit detail');
27
28
            $table->string('url')
29
                  ->description('The audit action URL');
30
31
            $table->string('ip')
32
                 ->description('The IP address')
33
                 ->notNull();
34
35
            $table->string('user_agent')
36
                  ->description('The user agent');
37
38
            $table->string('tags')
39
                  ->description('The audit tags');
40
41
            $table->datetime('date')
42
                    ->description('audit date')
43
                    ->notNull();
44
45
            $table->integer('user_id')
46
                    ->description('The audit user')
47
                    ->notNull();
48
49
            $table->foreign('user_id')
50
                    ->references('users', 'id')
51
                    ->onDelete('NO ACTION');
52
53
            $table->engine('INNODB');
54
        });
55
    }
56
57
    public function down(): void
58
    {
59
      //Action when migrate down
60
        $this->drop('audits');
61
    }
62
}
63