morphs('oSubject'); // 如果你之前已经有数据了,建议给这两个字段允许 null,防止迁移报错 // $table->morphs('oSubject')->nullable(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::table('articles', function (Blueprint $table) { // 降级操作:把这两个字段和索引一并撤销,保持数据库清爽 $table->dropMorphs('oSubject'); }); } };