forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2016_10_23_201624_add_foreign_allocations.php
More file actions
44 lines (38 loc) · 1.37 KB
/
2016_10_23_201624_add_foreign_allocations.php
File metadata and controls
44 lines (38 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddForeignAllocations extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('allocations', function (Blueprint $table) {
$table->integer('assigned_to', false, true)->nullable()->change();
$table->integer('node', false, true)->nullable(false)->change();
$table->foreign('assigned_to')->references('id')->on('servers');
$table->foreign('node')->references('id')->on('nodes');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('allocations', function (Blueprint $table) {
$table->dropForeign(['assigned_to']);
$table->dropIndex(['assigned_to']);
$table->dropForeign(['node']);
$table->dropIndex(['node']);
$table->mediumInteger('assigned_to', false, true)->nullable()->change();
$table->mediumInteger('node', false, true)->nullable(false)->change();
});
DB::statement('ALTER TABLE allocations
MODIFY COLUMN assigned_to MEDIUMINT(8) UNSIGNED NULL,
MODIFY COLUMN node MEDIUMINT(8) UNSIGNED NOT NULL
');
}
}