Skip to content

Commit 7dd32e7

Browse files
authored
Update 2024_06_27_123923_add_control_measure_table.php
fix mysql migration
1 parent 8bc6cb4 commit 7dd32e7

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

database/migrations/2024_06_27_123923_add_control_measure_table.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,33 @@ public function up(): void
2525
$control->measures()->sync([$control->measure_id]);
2626
}
2727

28-
if (DB::getDriverName() !== 'pgsql')
29-
Schema::table('controls', function (Blueprint $table) {
30-
$table->dropForeign(['controls_domain_id_foreign']);
31-
$table->dropForeign(['controls_measure_id_foreign']);
32-
});
28+
if (DB::getDriverName() !== 'pgsql') {
29+
if (DB::getDriverName() == 'mysql')
30+
Schema::table('controls', function (Blueprint $table) {
31+
$table->dropForeign(['domain_id']);
32+
$table->dropForeign(['measure_id']);
33+
});
34+
else
35+
Schema::table('controls', function (Blueprint $table) {
36+
$table->dropForeign(['controls_domain_id_foreign']);
37+
$table->dropForeign(['controls_measure_id_foreign']);
38+
});
39+
}
3340

34-
if (DB::getDriverName() === 'sqlite')
41+
if (DB::getDriverName() === 'sqlite') {
3542
// Could not drop column with sqlite
3643
Schema::table('controls', function (Blueprint $table) {
3744
$table->integer('domain_id')->nullable()->change();
3845
$table->integer('measure_id')->nullable()->change();
39-
});
46+
});
47+
}
4048
else
4149
// Drop columns
4250
Schema::table('controls', function (Blueprint $table) {
4351
$table->dropColumn(['domain_id']);
4452
$table->dropColumn(['measure_id']);
45-
});
53+
});
54+
4655
}
4756

4857
/**

0 commit comments

Comments
 (0)