mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-21 02:41:36 +00:00
36 lines
807 B
PHP
36 lines
807 B
PHP
<?php
|
|
|
|
use App\Models\Site;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('commands', function (Blueprint $table): void {
|
|
$table->id();
|
|
$table->unsignedInteger('site_id');
|
|
$table->string('name');
|
|
$table->text('command');
|
|
$table->timestamps();
|
|
});
|
|
|
|
foreach (Site::all() as $site) {
|
|
$site->commands()->createMany($site->type()->baseCommands());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('commands');
|
|
}
|
|
};
|