mirror of
https://github.com/pelican-dev/panel.git
synced 2026-05-04 18:00:48 +03:00
Populate new tags
This commit is contained in:
@@ -3,12 +3,30 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('eggs', function (Blueprint $table) {
|
||||
$table->text('tags');
|
||||
});
|
||||
|
||||
DB::table('eggs')->update(['tags' => '[]']);
|
||||
|
||||
$eggsWithNests = DB::table('eggs')
|
||||
->select(['eggs.id', 'nests.name'])
|
||||
->join('nests', 'nests.id', '=', 'eggs.nest_id')
|
||||
->get();
|
||||
|
||||
foreach ($eggsWithNests as $egg) {
|
||||
DB::table('eggs')
|
||||
->where('id', $egg->id)
|
||||
->update(['tags' => "[\"$egg->name\"]"]);
|
||||
}
|
||||
|
||||
Schema::table('eggs', function (Blueprint $table) {
|
||||
$table->dropForeign('service_options_nest_id_foreign');
|
||||
$table->dropColumn('nest_id');
|
||||
@@ -42,13 +60,14 @@ return new class extends Migration
|
||||
});
|
||||
|
||||
Schema::table('eggs', function (Blueprint $table) {
|
||||
$table->dropColumn('tags');
|
||||
$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) {
|
||||
$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')) {
|
||||
|
||||
Reference in New Issue
Block a user