File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
database/migrations/updates Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ use Statamic\Eloquent\Forms\SubmissionModel;
99return new class extends Migration {
1010 public function up()
1111 {
12+ if (Schema::hasColumn($this->prefix('form_submissions'), 'form')) {
13+ return;
14+ }
15+
1216 Schema::table($this->prefix('form_submissions'), function (Blueprint $table) {
1317 $table->string('form', 30)->nullable()->index()->after('id');
1418 });
@@ -24,7 +28,12 @@ return new class extends Migration {
2428 });
2529
2630 Schema::table($this->prefix('form_submissions'), function (Blueprint $table) {
27- $table->dropForeign(['form_id']);
31+ collect(Schema::getForeignKeys($this->prefix('form_submissions')))->each(function ($fk) use ($table) {
32+ if (count($fk['columns']) == 1 && in_array('form_id', $fk['columns'])) {
33+ $table->dropForeign(['form_id']);
34+ }
35+ });
36+
2837 $table->dropColumn('form_id');
2938 });
3039 }
You can’t perform that action at this time.
0 commit comments