<?php
/**
 * Migration class for the 'meeting_type_date_overrides' table.
 *
 * Stores date-specific schedule overrides for meeting types
 * (e.g. unavailable dates or custom hours on a specific day).
 *
 * @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 MeetingTypeDateOverridesTable
 */
class MeetingTypeDateOverridesTable extends Migration {

	/**
	 * Creates the 'meeting_type_date_overrides' table.
	 *
	 * @return void
	 */
	public function up(): void {
		Schema::create(
			$this->tablePrefix . 'meeting_type_date_overrides',
			function ( Blueprint $table ) {
				$table->id();
				$table->unsignedBigInteger( 'meeting_type_id' );
				$table->date( 'override_date' );
				$table->boolean( 'is_unavailable' )->default( 0 );
				$table->time( 'start_time' )->nullable();
				$table->time( 'end_time' )->nullable();
				$table->timestamps();

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

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