<?php
namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateTipHitsTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id'        => ['type' => 'INT', 'auto_increment' => true],
            'tip_id'    => ['type' => 'INT', 'null' => true], // null for global hits
            'hits'      => ['type' => 'INT', 'default' => 0],
            'last_accessed' => ['type' => 'DATETIME', 'null' => true],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->addUniqueKey('tip_id');
        $this->forge->createTable('tip_hits');
    }

    public function down()
    {
        $this->forge->dropTable('tip_hits');
    }
} 