Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
2.78% |
1 / 36 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CreateContactSegmentTable | |
2.78% |
1 / 36 |
|
50.00% |
1 / 2 |
5.68 | |
0.00% |
0 / 1 |
| up | |
0.00% |
0 / 35 |
|
0.00% |
0 / 1 |
2 | |||
| down | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Database\Migrations; |
| 4 | |
| 5 | use CodeIgniter\Database\Migration; |
| 6 | |
| 7 | class CreateContactSegmentTable extends Migration |
| 8 | { |
| 9 | public function up() |
| 10 | { |
| 11 | $this->forge->addField([ |
| 12 | |
| 13 | 'id' => [ |
| 14 | 'type' => 'INT', |
| 15 | 'constraint' => 11, |
| 16 | 'auto_increment' => true, |
| 17 | ], |
| 18 | |
| 19 | 'name' => [ |
| 20 | 'type' => 'VARCHAR', |
| 21 | 'constraint' => 150, |
| 22 | ], |
| 23 | |
| 24 | /** |
| 25 | * RULE BUILDER (JSON) |
| 26 | * ex: AND / OR conditions |
| 27 | */ |
| 28 | 'rules' => [ |
| 29 | 'type' => 'JSON', |
| 30 | 'null' => true, |
| 31 | ], |
| 32 | |
| 33 | /** |
| 34 | * COMPTE CACHE (optionnel optimisation) |
| 35 | */ |
| 36 | 'contacts_count' => [ |
| 37 | 'type' => 'INT', |
| 38 | 'constraint' => 11, |
| 39 | 'default' => 0, |
| 40 | ], |
| 41 | |
| 42 | 'status' => [ |
| 43 | 'type' => 'ENUM', |
| 44 | 'constraint' => ['active', 'inactive'], |
| 45 | 'default' => 'active', |
| 46 | ], |
| 47 | |
| 48 | 'created_at' => [ |
| 49 | 'type' => 'DATETIME', |
| 50 | 'null' => true, |
| 51 | ], |
| 52 | |
| 53 | 'updated_at' => [ |
| 54 | 'type' => 'DATETIME', |
| 55 | 'null' => true, |
| 56 | ], |
| 57 | ]); |
| 58 | |
| 59 | $this->forge->addKey('id', true); |
| 60 | $this->forge->createTable('contact_segment'); |
| 61 | } |
| 62 | |
| 63 | public function down() |
| 64 | { |
| 65 | $this->forge->dropTable('contact_segment'); |
| 66 | } |
| 67 | } |