<?php
 use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { public function up(): void { Schema::create('kb_votes', function (Blueprint $t) { $t->id(); $t->unsignedBigInteger('post_id'); $t->unsignedBigInteger('client_id')->nullable(); $t->string('ip_address', 45)->nullable(); $t->enum('vote', ['helpful','not_helpful']); $t->timestamp('created_at')->nullable(); $t->timestamp('updated_at')->nullable(); $t->index('client_id', 'kb_votes_client_id_foreign'); $t->unique(['post_id', 'client_id'], 'kb_votes_post_id_client_id_unique'); $t->unique(['post_id', 'ip_address'], 'kb_votes_post_id_ip_address_unique'); $t->index(['post_id', 'vote'], 'kb_votes_post_id_vote_index'); $t->foreign('client_id', 'kb_votes_client_id_foreign')->references('id')->on('clients')->onDelete('cascade'); $t->foreign('post_id', 'kb_votes_post_id_foreign')->references('id')->on('posts')->onDelete('cascade'); }); } public function down(): void { Schema::dropIfExists('kb_votes'); } }; 