<?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_SCREENS;
        $this->columns = [
            "`id` bigint NOT NULL AUTO_INCREMENT",
            "`flyer_image_id` bigint NOT NULL",
            "`screen_name` VARCHAR(30)",
            "`screen_width` INT(11)",
            "`screen_height` INT(11)",
            "`elements` LONGTEXT",
            "`background_image` LONGTEXT",
            "PRIMARY KEY (`id`)",
        ];

        $this->queries[] = "ALTER TABLE `{$this->table_name($this->table)}` ADD INDEX `IDX_flyer_image_id` (`flyer_image_id`)";
    }

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