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
43 lines (37 loc) · 1.25 KB
/
2016_10_23_201624_add_foreign_allocations.php
File metadata and controls
43 lines (37 loc) · 1.25 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
<?php
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()
{
DB::statement('ALTER TABLE allocations
MODIFY COLUMN assigned_to INT(10) UNSIGNED NULL,
MODIFY COLUMN node INT(10) UNSIGNED NOT NULL
');
Schema::table('allocations', function (Blueprint $table) {
$table->foreign('assigned_to')->references('id')->on('servers');
$table->foreign('node')->references('id')->on('nodes');
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::table('allocations', function (Blueprint $table) {
$table->dropForeign('allocations_assigned_to_foreign');
$table->dropForeign('allocations_node_foreign');
$table->dropIndex('allocations_assigned_to_foreign');
$table->dropIndex('allocations_node_foreign');
});
DB::statement('ALTER TABLE allocations
MODIFY COLUMN assigned_to MEDIUMINT(8) UNSIGNED NULL,
MODIFY COLUMN node MEDIUMINT(8) UNSIGNED NOT NULL
');
}
}