/ database / migrations / 2023_05_11_202533_create_toe_vulnerabilities_table.php
2023_05_11_202533_create_toe_vulnerabilities_table.php
 1  <?php
 2  
 3  use App\Models\User;
 4  use Illuminate\Database\Migrations\Migration;
 5  use Illuminate\Database\Schema\Blueprint;
 6  use Illuminate\Support\Facades\Schema;
 7  
 8  return new class extends Migration
 9  {
10      /**
11       * Run the migrations.
12       *
13       * @return void
14       */
15      public function up()
16      {
17          Schema::create('toe_vulnerability', function (Blueprint $table) {
18              $table->id();
19  
20              $table->foreignId('toe_id')->constrained('toes');
21              $table->foreignId('vulnerability_id')->constrained('vulnerabilities');
22              $table->boolean('applies')->default(0);
23              $table->text('rationale')->nullable();
24              $table->timestamp('reviewed_at')->nullable();
25              $table->foreignIdFor(User::class, 'reviewed_by')->nullable();
26  
27              $table->unique(['vulnerability_id', 'toe_id']);
28              $table->timestamps();
29          });
30      }
31  
32      /**
33       * Reverse the migrations.
34       *
35       * @return void
36       */
37      public function down()
38      {
39          Schema::dropIfExists('toe_vulnerability');
40      }
41  };