2023_05_30_210253_create_json_drafts_table.php
1 <?php 2 3 use Illuminate\Database\Migrations\Migration; 4 use Illuminate\Database\Schema\Blueprint; 5 use Illuminate\Support\Facades\Schema; 6 7 return new class extends Migration 8 { 9 /** 10 * Run the migrations. 11 * 12 * @return void 13 */ 14 public function up() 15 { 16 Schema::create('json_drafts', function (Blueprint $table) { 17 $table->id(); 18 $table->boolean('completed')->default(false)->index(); 19 $table->string('schema_name')->index(); 20 $table->string('json_id')->index()->nullable(); 21 $table->foreignId('dossier_id')->constrained('dossiers')->onDelete('cascade'); 22 $table->foreignId('validation_id')->constrained('validations')->cascadeOnUpdate()->cascadeOnDelete(); 23 $table->json('json'); 24 $table->timestamps(); 25 26 $table->unique(['schema_name','dossier_id','json_id']); 27 }); 28 } 29 30 /** 31 * Reverse the migrations. 32 * 33 * @return void 34 */ 35 public function down() 36 { 37 Schema::dropIfExists('json_drafts'); 38 } 39 };