db->tableExists('activity_logs')) { $this->forge->dropTable('activity_logs', true); } } public function down(): void { $this->forge->addField([ 'id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true, ], 'user_id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true, ], 'user_role' => [ 'type' => 'ENUM', 'constraint' => ['admin', 'doctor', 'patient', 'system'], 'null' => true, ], 'action' => [ 'type' => 'VARCHAR', 'constraint' => 100, ], 'description' => [ 'type' => 'TEXT', 'null' => true, ], 'target_type' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true, ], 'target_id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true, ], 'ip_address' => [ 'type' => 'VARCHAR', 'constraint' => 45, 'null' => true, ], 'user_agent' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true, ], 'created_at' => [ 'type' => 'DATETIME', 'null' => false, ], ]); $this->forge->addPrimaryKey('id'); $this->forge->addKey('user_id'); $this->forge->addKey('action'); $this->forge->addKey('created_at'); $this->forge->createTable('activity_logs', true); } }