forge->addField([ 'id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true, ], 'user_id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true, ], 'action' => [ 'type' => 'VARCHAR', 'constraint' => 100, ], 'ip_address' => [ 'type' => 'VARCHAR', 'constraint' => 45, ], 'user_agent' => [ 'type' => 'TEXT', 'null' => true, ], 'created_at' => [ 'type' => 'DATETIME', 'null' => true, ], ]); $this->forge->addKey('id', true); $this->forge->addKey('user_id'); $this->forge->addKey('action'); $this->forge->addKey('created_at'); $this->forge->addForeignKey('user_id', 'users', 'id', 'SET NULL', 'CASCADE'); $this->forge->createTable('audit_logs', true, ['ENGINE' => 'InnoDB']); } public function down() { $this->forge->dropTable('audit_logs'); } }