Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
1.54% |
1 / 65 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CreateNotificationRuleTable | |
1.54% |
1 / 65 |
|
50.00% |
1 / 2 |
5.82 | |
0.00% |
0 / 1 |
| up | |
0.00% |
0 / 64 |
|
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 CreateNotificationRuleTable extends Migration |
| 8 | { |
| 9 | public function up() |
| 10 | { |
| 11 | $this->forge->addField([ |
| 12 | |
| 13 | /** |
| 14 | * ========================= |
| 15 | * IDENTIFIANT |
| 16 | * ========================= |
| 17 | */ |
| 18 | 'id' => [ |
| 19 | 'type' => 'INT', |
| 20 | 'constraint' => 11, |
| 21 | 'unsigned' => true, |
| 22 | 'auto_increment' => true, |
| 23 | ], |
| 24 | |
| 25 | /** |
| 26 | * ========================= |
| 27 | * IDENTIFICATION REGLE |
| 28 | * ========================= |
| 29 | */ |
| 30 | 'rule_name' => [ |
| 31 | 'type' => 'VARCHAR', |
| 32 | 'constraint' => 255, |
| 33 | ], |
| 34 | |
| 35 | /** |
| 36 | * ========================= |
| 37 | * LOGIQUE METIER |
| 38 | * ========================= |
| 39 | */ |
| 40 | 'conditions' => [ |
| 41 | 'type' => 'JSON', |
| 42 | 'null' => true, |
| 43 | ], |
| 44 | |
| 45 | /** |
| 46 | * ========================= |
| 47 | * TEMPLATES MULTI-CANAUX |
| 48 | * ========================= |
| 49 | */ |
| 50 | 'template' => [ |
| 51 | 'type' => 'JSON', |
| 52 | 'null' => true, |
| 53 | ], |
| 54 | |
| 55 | /** |
| 56 | * ========================= |
| 57 | * TIMING / SCHEDULING |
| 58 | * ========================= |
| 59 | */ |
| 60 | 'delay_type' => [ |
| 61 | 'type' => 'ENUM', |
| 62 | 'constraint' => ['before', 'after', 'on_date'], |
| 63 | 'default' => 'before', |
| 64 | ], |
| 65 | |
| 66 | 'delay_value' => [ |
| 67 | 'type' => 'INT', |
| 68 | 'constraint' => 11, |
| 69 | 'default' => 0, |
| 70 | ], |
| 71 | |
| 72 | 'on_date' => [ |
| 73 | 'type' => 'DATE', |
| 74 | 'null' => true, |
| 75 | ], |
| 76 | |
| 77 | 'on_dates' => [ |
| 78 | 'type' => 'JSON', |
| 79 | 'null' => true, |
| 80 | ], |
| 81 | |
| 82 | /** |
| 83 | * ========================= |
| 84 | * ETAT |
| 85 | * ========================= |
| 86 | */ |
| 87 | 'status' => [ |
| 88 | 'type' => 'ENUM', |
| 89 | 'constraint' => ['draft', 'active', 'inactive'], |
| 90 | 'default' => 'draft', |
| 91 | ], |
| 92 | |
| 93 | 'is_active' => [ |
| 94 | 'type' => 'TINYINT', |
| 95 | 'default' => 1, |
| 96 | ], |
| 97 | |
| 98 | /** |
| 99 | * ========================= |
| 100 | * EXTENSION FLEXIBLE |
| 101 | * ========================= |
| 102 | */ |
| 103 | 'metadata' => [ |
| 104 | 'type' => 'JSON', |
| 105 | 'null' => true, |
| 106 | ], |
| 107 | |
| 108 | /** |
| 109 | * ========================= |
| 110 | * TIMESTAMPS |
| 111 | * ========================= |
| 112 | */ |
| 113 | 'created_at' => [ |
| 114 | 'type' => 'DATETIME', |
| 115 | 'null' => true, |
| 116 | ], |
| 117 | |
| 118 | 'updated_at' => [ |
| 119 | 'type' => 'DATETIME', |
| 120 | 'null' => true, |
| 121 | ], |
| 122 | ]); |
| 123 | |
| 124 | $this->forge->addKey('id', true); |
| 125 | |
| 126 | /** |
| 127 | * ========================= |
| 128 | * INDEX STRATEGIQUE |
| 129 | * ========================= |
| 130 | */ |
| 131 | |
| 132 | // règles actives |
| 133 | $this->forge->addKey(['status', 'is_active']); |
| 134 | |
| 135 | // optimisation scheduling |
| 136 | $this->forge->addKey('delay_type'); |
| 137 | |
| 138 | // performance listing |
| 139 | $this->forge->addKey('created_at'); |
| 140 | |
| 141 | $this->forge->createTable('notification_rule', true); |
| 142 | } |
| 143 | |
| 144 | public function down() |
| 145 | { |
| 146 | $this->forge->dropTable('notification_rule', true); |
| 147 | } |
| 148 | } |