Possible YABs foreign keys migrations error fix

Possible YABs foreign keys migrations error fix
This commit is contained in:
cp6 2022-07-25 10:33:54 +10:00
parent 20058cb9c9
commit 59b3138dfb
2 changed files with 11 additions and 5 deletions

View File

@ -2,6 +2,7 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
@ -9,13 +10,17 @@ return new class extends Migration
public function up()
{
Schema::table('disk_speed', function (Blueprint $table) {
$table->dropForeign('ds_fk_yabs');
if (env('DB_CONNECTION') !== 'sqlite') {
$table->dropForeign('ds_fk_yabs');
}
$table->foreign('id', 'ds_fk_yabs')->references('id')->on('yabs')->onDelete('cascade');
});
Schema::table('network_speed', function (Blueprint $table) {
$table->dropForeign('ns_fk_yabs');
if (env('DB_CONNECTION') !== 'sqlite') {
$table->dropForeign('ns_fk_yabs');
}
$table->foreign('id', 'ns_fk_yabs')->references('id')->on('yabs')->onDelete('cascade');
});

View File

@ -4,12 +4,13 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
return new class extends Migration {
public function up()
{
Schema::table('yabs', function (Blueprint $table) {
$table->dropForeign('yabs_fk_servers');
if (env('DB_CONNECTION') !== 'sqlite') {
$table->dropForeign('yabs_fk_servers');
}
$table->foreign('server_id', 'yabs_fk_servers')->references('id')->on('servers')->onDelete('cascade');
});