Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
1.27% covered (danger)
1.27%
1 / 79
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CreateProviderEnvironmentTable
1.27% covered (danger)
1.27%
1 / 79
50.00% covered (danger)
50.00%
1 / 2
5.85
0.00% covered (danger)
0.00%
0 / 1
 up
0.00% covered (danger)
0.00%
0 / 78
0.00% covered (danger)
0.00%
0 / 1
2
 down
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Modules\SecurityModule\Database\Migrations;
4
5use CodeIgniter\Database\Migration;
6
7class CreateProviderEnvironmentTable extends Migration
8{
9    public function up()
10    {
11        $this->forge->addField([
12
13            'id' => [
14                'type'           => 'INT',
15                'constraint'     => 11,
16                'unsigned'       => true,
17                'auto_increment' => true,
18            ],
19
20            'channel_provider_id' => [
21                'type'       => 'INT',
22                'constraint' => 11,
23                'unsigned'   => true,
24            ],
25
26            'country_code' => [
27                'type'       => 'VARCHAR',
28                'constraint' => 10,
29            ],
30
31            /*
32            |--------------------------------------------------------------------------
33            | MODE EXECUTION
34            |--------------------------------------------------------------------------
35            */
36            'mode' => [
37                'type'       => 'ENUM',
38                'constraint' => ['sandbox', 'production'],
39                'default'    => 'production',
40            ],
41
42            /*
43            |--------------------------------------------------------------------------
44            | ACTIVATION
45            |--------------------------------------------------------------------------
46            */
47            'is_active' => [
48                'type'       => 'TINYINT',
49                'constraint' => 1,
50                'default'    => 1,
51            ],
52
53            /*
54            |--------------------------------------------------------------------------
55            | TESTING DATA (RUNTIME ONLY)
56            |--------------------------------------------------------------------------
57            */
58            'test_number' => [
59                'type'       => 'VARCHAR',
60                'constraint' => 50,
61                'null'       => true,
62            ],
63
64            'test_email' => [
65                'type'       => 'VARCHAR',
66                'constraint' => 120,
67                'null'       => true,
68            ],
69
70            /*
71            |--------------------------------------------------------------------------
72            | INFRASTRUCTURE
73            |--------------------------------------------------------------------------
74            */
75            'sandbox_url' => [
76                'type'       => 'VARCHAR',
77                'constraint' => 255,
78                'null'       => true,
79            ],
80
81            /*
82            |--------------------------------------------------------------------------
83            | PERFORMANCE
84            |--------------------------------------------------------------------------
85            */
86            'timeout_ms' => [
87                'type'       => 'INT',
88                'constraint' => 11,
89                'default'    => 5000,
90            ],
91
92            'retry_policy_json' => [
93                'type' => 'TEXT',
94                'null' => true,
95            ],
96
97            /*
98            |--------------------------------------------------------------------------
99            | EXTENSIBLE CONFIG
100            |--------------------------------------------------------------------------
101            */
102            'config_json' => [
103                'type' => 'TEXT',
104                'null' => true,
105            ],
106
107            /*
108            |--------------------------------------------------------------------------
109            | OBSERVABILITY
110            |--------------------------------------------------------------------------
111            */
112            'last_test_status' => [
113                'type'       => 'VARCHAR',
114                'constraint' => 50,
115                'null'       => true,
116            ],
117
118            'last_test_at' => [
119                'type' => 'DATETIME',
120                'null' => true,
121            ],
122
123            /*
124            |--------------------------------------------------------------------------
125            | TIMESTAMPS
126            |--------------------------------------------------------------------------
127            */
128            'created_at' => [
129                'type' => 'DATETIME',
130                'null' => true,
131            ],
132
133            'updated_at' => [
134                'type' => 'DATETIME',
135                'null' => true,
136            ],
137        ]);
138
139        $this->forge->addKey('id', true);
140
141        $this->forge->addKey('channel_provider_id');
142        $this->forge->addKey('country_code');
143        $this->forge->addKey(['channel_provider_id', 'country_code']);
144        $this->forge->addKey('mode');
145
146        $this->forge->createTable('provider_environment', true);
147    }
148
149    public function down()
150    {
151        $this->forge->dropTable('provider_environment', true);
152    }
153}