<?php
/**
 * Created by PhpStorm.
 * User: Pritom
 * Date: 5/16/2024
 * Time: 12:00 AM
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

use Flyerimage\Core\Database\MigrationBase;

return new class extends MigrationBase  {
    public function up() {
        $this->table = \Flyerimage\App\Constants\ITables::$FLYER_IMAGES_HISTORY;
        $this->columns = [
            "`id` bigint NOT NULL AUTO_INCREMENT",
            "`image_path` VARCHAR(300) NOT NULL",
            "`used_by` bigint NULL DEFAULT 0",
            "`created_at` DATE NOT NULL",
            "PRIMARY KEY (`id`)",
        ];
        $this->queries[] = "ALTER TABLE `{$this->table_name($this->table)}` ADD INDEX `IDX_used_by` (`used_by`)";
        $this->queries[] = "ALTER TABLE `{$this->table_name($this->table)}` ADD INDEX `IDX_created_at` (`created_at`)";
    }

    public function down() {
        $this->table = \Flyerimage\App\Constants\ITables::$FLYER_IMAGES_HISTORY;
        $this->queries[] = "DROP TABLE IF EXISTS {$this->table_name($this->table)}";
    }
};