<?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_PAGES;
        $this->columns = [
            "`id` bigint NOT NULL AUTO_INCREMENT",
            "`flyer_image_id` bigint NOT NULL",
            "`type` VARCHAR(20) NOT NULL",
            "`value` TEXT NOT NULL",
            "PRIMARY KEY (`id`)",
        ];
        $this->queries[] = "ALTER TABLE `{$this->table_name($this->table)}` ADD INDEX `IDX_flyer_image_id` (`flyer_image_id`)";
        $this->queries[] = "ALTER TABLE `{$this->table_name($this->table)}` ADD INDEX `IDX_type` (`type`)";
    }

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