Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/database/migrations/2016_08_30_212718_add_ip_alias.php
7460 views
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class AddIpAlias extends Migration
8
{
9
/**
10
* Run the migrations.
11
*/
12
public function up(): void
13
{
14
Schema::table('allocations', function (Blueprint $table) {
15
$table->text('ip_alias')->nullable()->after('ip');
16
});
17
18
$allocations = DB::select('SELECT id, ip FROM allocations');
19
foreach ($allocations as $allocation) {
20
DB::update(
21
'UPDATE allocations SET ip_alias = :ip WHERE id = :id',
22
[
23
'ip' => $allocation->ip,
24
'id' => $allocation->id,
25
]
26
);
27
}
28
}
29
30
/**
31
* Reverse the migrations.
32
*/
33
public function down(): void
34
{
35
Schema::table('allocations', function (Blueprint $table) {
36
$table->dropColumn('ip_alias');
37
});
38
}
39
}
40
41