<?php
/**
 * Migration class for the 'meeting_type_availability' table.
 *
 * Stores weekly availability windows for each meeting type.
 *
 * @package RadiusTheme\RadiusBooking
 * @since   1.2.0
 */

namespace RadiusTheme\RadiusBooking\Databases\Table;

use RadiusTheme\RadiusBooking\Core\Database\Schema\Blueprint;
use RadiusTheme\RadiusBooking\Abstracts\Migration;
use RadiusTheme\RadiusBooking\Core\Database\Schema\Schema;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class MeetingTypeAvailabilityTable
 */
class MeetingTypeAvailabilityTable extends Migration {

	/**
	 * Creates the 'meeting_type_availability' table.
	 *
	 * @return void
	 */
	public function up(): void {
		Schema::create(
			$this->tablePrefix . 'meeting_type_availability',
			function ( Blueprint $table ) {
				$table->id();
				$table->unsignedBigInteger( 'meeting_type_id' );
				$table->tinyInteger( 'day_of_week' )->comment( '0=Sun, 1=Mon, ..., 6=Sat' );
				$table->time( 'start_time' );
				$table->time( 'end_time' );
				$table->boolean( 'is_enabled' )->default( 1 );
				$table->timestamps();

				$table->index( 'meeting_type_id' );
			}
		);
	}

	/**
	 * Drops the meeting_type_availability table.
	 *
	 * @return void
	 */
	public function down(): void {
		Schema::drop( $this->tablePrefix . 'meeting_type_availability' );
	}
}
