	<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
	/**
	 * Run the migrations.
	 */
	public function up(): void {
		Schema::create('site_management_component_fields', function (Blueprint $table) {
			$table->id();
			$table->timestamps();
			$table->softDeletes();
			$table->unsignedBigInteger('created_by')->nullable();
			$table->unsignedBigInteger('updated_by')->nullable();
			$table->unsignedBigInteger('deleted_by')->nullable();

			$table->foreignId('site_management_component_id')
				->constrained(table: 'site_management_components', indexName: 'smcf_smc_fk')
				->onUpdate('cascade')
				->onDelete('cascade');

			$table->foreignId('site_management_field_type_id')
				->constrained(table: 'site_management_field_types', indexName: 'smcf_smft_fk')
				->onUpdate('cascade')
				->onDelete('cascade');

			$table->string('label', 127)->nullable();
			$table->string('value', 127)->nullable();
			$table->boolean('is_required')->default(false);
		});
	}

	/**
	 * Reverse the migrations.
	 */
	public function down(): void {
		Schema::dropIfExists('site_management_component_fields');
	}
};
