<?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('blogs', 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('blog_category_id')
				->constrained()
				->onUpdate('cascade')
				->onDelete('cascade');

			$table->string('title', 127)->nullable();
			$table->string('subtitle', 127)->nullable();
			$table->string('slug', 127)->unique();
			$table->string('descr', 511)->nullable();
			$table->mediumText('content')->nullable();
			$table->string('image', 127)->nullable();
			$table->dateTime('scheduling_date')->nullable();
			$table->unsignedInteger('count_views')->default(0);
			$table->unsignedInteger('count_comments')->default(0);
			$table->unsignedInteger('count_likes')->default(0);
		});
	}

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