<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id');
            $table->text('image_url')->nullable();
            $table->string('latitude',100)->nullable();
            $table->string('longitude',100)->nullable();
            $table->foreignId('place_id')->nullable()->constrained('places')->nullOnDelete();
            $table->string('google_place_name',100)->nullable();
            $table->string('google_place_id',100)->nullable();
            $table->string('google_place_url',100)->nullable();
            $table->string('google_place_address',100)->nullable();

            $table->text('description')->nullable();
            $table->foreignId('province_id')->nullable()->constrained('provinces')->nullOnDelete();

            $table->integer('like_count')->default(0);
            $table->integer('comment_count')->default(0);

            $table->string('type',100)->nullable();

            $table->string('language_code',2)->nullable();
            $table->boolean('enable_comment')->default(true);

            $table->boolean('is_public')->default(true);
            $table->boolean('status')->default(true);
            //hashtags
            $table->timestamps();
        });
    }

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