Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
3.57% |
2 / 56 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CreateSystemTable | |
3.57% |
2 / 56 |
|
50.00% |
1 / 2 |
5.59 | |
0.00% |
0 / 1 |
| up | |
0.00% |
0 / 54 |
|
0.00% |
0 / 1 |
2 | |||
| down | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Database\Migrations; |
| 4 | |
| 5 | use CodeIgniter\Database\Migration; |
| 6 | |
| 7 | class CreateSystemTable extends Migration |
| 8 | { |
| 9 | public function up() |
| 10 | { |
| 11 | /* |
| 12 | |-------------------------------------------------------------------------- |
| 13 | | SYSTEM STATE |
| 14 | |-------------------------------------------------------------------------- |
| 15 | */ |
| 16 | $this->forge->addField([ |
| 17 | 'id' => [ |
| 18 | 'type' => 'INT', |
| 19 | 'constraint' => 11, |
| 20 | 'unsigned' => true, |
| 21 | 'auto_increment' => true, |
| 22 | ], |
| 23 | |
| 24 | 'state_key' => [ |
| 25 | 'type' => 'VARCHAR', |
| 26 | 'constraint' => 150, |
| 27 | ], |
| 28 | |
| 29 | 'state_value' => [ |
| 30 | 'type' => 'TEXT', |
| 31 | 'null' => true, |
| 32 | ], |
| 33 | |
| 34 | 'created_at' => [ |
| 35 | 'type' => 'DATETIME', |
| 36 | 'null' => true, |
| 37 | ], |
| 38 | |
| 39 | 'updated_at' => [ |
| 40 | 'type' => 'DATETIME', |
| 41 | 'null' => true, |
| 42 | ], |
| 43 | ]); |
| 44 | |
| 45 | $this->forge->addKey('id', true); |
| 46 | $this->forge->addUniqueKey('state_key'); |
| 47 | |
| 48 | $this->forge->createTable('system_state'); |
| 49 | |
| 50 | /* |
| 51 | |-------------------------------------------------------------------------- |
| 52 | | SYSTEM MODULES |
| 53 | |-------------------------------------------------------------------------- |
| 54 | */ |
| 55 | |
| 56 | $this->forge->addField([ |
| 57 | 'id' => [ |
| 58 | 'type' => 'INT', |
| 59 | 'constraint' => 11, |
| 60 | 'unsigned' => true, |
| 61 | 'auto_increment' => true, |
| 62 | ], |
| 63 | |
| 64 | 'module_name' => [ |
| 65 | 'type' => 'VARCHAR', |
| 66 | 'constraint' => 100, |
| 67 | ], |
| 68 | |
| 69 | 'module_version' => [ |
| 70 | 'type' => 'VARCHAR', |
| 71 | 'constraint' => 20, |
| 72 | ], |
| 73 | |
| 74 | 'is_enabled' => [ |
| 75 | 'type' => 'TINYINT', |
| 76 | 'constraint' => 1, |
| 77 | 'default' => 1, |
| 78 | ], |
| 79 | |
| 80 | 'installed_at' => [ |
| 81 | 'type' => 'DATETIME', |
| 82 | 'null' => true, |
| 83 | ], |
| 84 | ]); |
| 85 | |
| 86 | $this->forge->addKey('id', true); |
| 87 | |
| 88 | $this->forge->createTable('system_module'); |
| 89 | } |
| 90 | |
| 91 | public function down() |
| 92 | { |
| 93 | $this->forge->dropTable('system_module'); |
| 94 | $this->forge->dropTable('system_state'); |
| 95 | } |
| 96 | } |