hasTable('notes_subjects')) { Capsule::schema()->create('notes_subjects', function (Blueprint $table) { $table->id('subjects_id'); $table->unsignedBigInteger('subjects_idbus')->nullable(); $table->unsignedBigInteger('subjects_iduser')->nullable(); $table->string('subjects_name'); $table->string('subjects_color')->default('#6c757d'); $table->timestamps(); $table->index('subjects_idbus'); $table->index('subjects_iduser'); }); } // Update notes table to use subject_id if (Capsule::schema()->hasTable('notes')) { Capsule::schema()->table('notes', function (Blueprint $table) { if (!Capsule::schema()->hasColumn('notes', 'notes_subject_id')) { $table->unsignedBigInteger('notes_subject_id')->nullable()->after('notes_type'); $table->index('notes_subject_id'); } }); } } /** * Reverse the migrations. * * @return void */ public function down(): void { if (Capsule::schema()->hasTable('notes')) { Capsule::schema()->table('notes', function (Blueprint $table) { if (Capsule::schema()->hasColumn('notes', 'notes_subject_id')) { $table->dropColumn('notes_subject_id'); } }); } Capsule::schema()->dropIfExists('notes_subjects'); } }