<?php
/**
 * Migration class for the 'employees_special_day_time_periods_services' table.
 */

namespace RadiusTheme\RadiusBooking\Databases\Table;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
use RadiusTheme\RadiusBooking\Core\Database\Schema\Blueprint;
use RadiusTheme\RadiusBooking\Abstracts\Migration;
use RadiusTheme\RadiusBooking\Core\Database\Schema\Schema;
/**
 * Class EmployeesSpecialDayTimePeriodsServicesTable
 *
 * @package RadiusTheme\RadiusBooking\Databases\Table
 * Migration for creating the 'employees_special_day_time_periods_services' table.
 */
class EmployeesSpecialDayTimePeriodsServicesTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up(): void {
		// Rename old long table name to shorter one for MySQL 64-char identifier limit.
		Schema::rename(
			$this->tablePrefix . 'employees_special_day_time_periods_services',
			$this->tablePrefix . 'emp_spday_tp_services'
		);

		Schema::create(
			$this->tablePrefix . 'emp_spday_tp_services',
			function ( Blueprint $table ) {
				$table->id();
				$table->unsignedBigInteger( 'special_day_time_period_id' )->index();
				$table->unsignedBigInteger( 'service_id' )->index();
				$table->timestamps();
			}
		);
	}

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