mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 15:34:44 +02:00
Populate tags for nodes
This commit is contained in:
parent
8ce84239e1
commit
f6eede37aa
@ -27,6 +27,7 @@ return new class extends Migration
|
|||||||
->update(['tags' => "[\"$egg->name\"]"]);
|
->update(['tags' => "[\"$egg->name\"]"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Schema::table('eggs', function (Blueprint $table) {
|
Schema::table('eggs', function (Blueprint $table) {
|
||||||
$table->dropForeign('service_options_nest_id_foreign');
|
$table->dropForeign('service_options_nest_id_foreign');
|
||||||
$table->dropColumn('nest_id');
|
$table->dropColumn('nest_id');
|
||||||
@ -44,6 +45,7 @@ return new class extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not really reversible, but...
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::table('api_keys', function (Blueprint $table) {
|
Schema::table('api_keys', function (Blueprint $table) {
|
||||||
@ -62,12 +64,12 @@ return new class extends Migration
|
|||||||
Schema::table('eggs', function (Blueprint $table) {
|
Schema::table('eggs', function (Blueprint $table) {
|
||||||
$table->dropColumn('tags');
|
$table->dropColumn('tags');
|
||||||
$table->mediumInteger('nest_id')->unsigned();
|
$table->mediumInteger('nest_id')->unsigned();
|
||||||
// $table->foreign(['nest_id'], 'service_options_nest_id_foreign');
|
$table->foreign(['nest_id'], 'service_options_nest_id_foreign');
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::table('servers', function (Blueprint $table) {
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
$table->mediumInteger('nest_id')->unsigned();
|
$table->mediumInteger('nest_id')->unsigned();
|
||||||
// $table->foreign(['nest_id'], 'servers_nest_id_foreign');
|
$table->foreign(['nest_id'], 'servers_nest_id_foreign');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (class_exists('Database\Seeders\NestSeeder')) {
|
if (class_exists('Database\Seeders\NestSeeder')) {
|
||||||
|
@ -2,15 +2,30 @@
|
|||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
Schema::table('nodes', function (Blueprint $table) {
|
||||||
|
$table->text('tags');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::table('nodes')->update(['tags' => '[]']);
|
||||||
|
|
||||||
|
$nodesWithLocations = DB::table('nodes')
|
||||||
|
->select(['nodes.id', 'locations.short'])
|
||||||
|
->join('locations', 'locations.id', '=', 'nodes.location_id')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($nodesWithLocations as $node) {
|
||||||
|
DB::table('nodes')
|
||||||
|
->where('id', $node->id)
|
||||||
|
->update(['tags' => "[\"$node->short\"]"]);
|
||||||
|
}
|
||||||
|
|
||||||
Schema::table('nodes', function (Blueprint $table) {
|
Schema::table('nodes', function (Blueprint $table) {
|
||||||
$table->dropForeign('nodes_location_id_foreign');
|
$table->dropForeign('nodes_location_id_foreign');
|
||||||
$table->dropColumn('location_id');
|
$table->dropColumn('location_id');
|
||||||
@ -23,9 +38,7 @@ return new class extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Not really reversible, but...
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::create('locations', function (Blueprint $table) {
|
Schema::create('locations', function (Blueprint $table) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user