Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 81
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CreateSupportIncidentTable
0.00% covered (danger)
0.00%
0 / 81
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 up
0.00% covered (danger)
0.00%
0 / 80
0.00% covered (danger)
0.00%
0 / 1
2
 down
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Database\Migrations;
4
5use CodeIgniter\Database\Migration;
6
7class CreateSupportIncidentTable extends Migration
8{
9    public function up()
10    {
11        $this->forge->addField([
12            'id' => [
13                'type'           => 'BIGINT',
14                'constraint'     => 20,
15                'unsigned'       => true,
16                'auto_increment' => true,
17            ],
18
19            'organization_id' => [
20                'type'       => 'BIGINT',
21                'constraint' => 20,
22                'unsigned'   => true,
23            ],
24
25            'user_id' => [
26                'type'       => 'BIGINT',
27                'constraint' => 20,
28                'unsigned'   => true,
29                'null'       => true,
30            ],
31
32            'project' => [
33                'type'       => 'VARCHAR',
34                'constraint' => 100,
35                'null'       => true,
36            ],
37
38            'environment' => [
39                'type'       => 'VARCHAR',
40                'constraint' => 50,
41                'null'       => true,
42            ],
43
44            'type' => [
45                'type'       => 'VARCHAR',
46                'constraint' => 50,
47            ],
48
49            'severity' => [
50                'type'       => 'VARCHAR',
51                'constraint' => 20,
52                'null'       => true,
53            ],
54
55            'message' => [
56                'type' => 'TEXT',
57            ],
58
59            'payload_json' => [
60                'type' => 'LONGTEXT',
61                'null' => true,
62            ],
63
64            'url' => [
65                'type' => 'TEXT',
66                'null' => true,
67            ],
68
69            'stack_trace' => [
70                'type' => 'LONGTEXT',
71                'null' => true,
72            ],
73
74            'status' => [
75                'type'       => 'VARCHAR',
76                'constraint' => 20,
77                'default'    => 'new',
78            ],
79
80            'source' => [
81                'type'       => 'VARCHAR',
82                'constraint' => 50,
83                'null'       => true,
84            ],
85
86            'created_at' => [
87                'type' => 'DATETIME',
88                'null' => true,
89            ],
90
91            'updated_at' => [
92                'type' => 'DATETIME',
93                'null' => true,
94            ],
95        ]);
96
97        $this->forge->addKey('id', true);
98
99        // indexes métier
100        $this->forge->addKey('organization_id');
101        $this->forge->addKey('status');
102        $this->forge->addKey('severity');
103        $this->forge->addKey('type');
104        $this->forge->addKey('created_at');
105
106        $this->forge->createTable('support_incident', true, [
107            'ENGINE' => 'InnoDB',
108        ]);
109    }
110
111    public function down()
112    {
113        $this->forge->dropTable('support_incident', true);
114    }
115}