forged-plugs/subdomains/database/migrations/002_create_subdomains_table.php
Pelican Installer Bot a43d377930 feat: forged-plugs — 17 plugins for Forge Panel
Separated from pelican-dev/plugins, rebranded for Forge.
Includes manifest.json for in-panel store browsing.
2026-05-17 13:43:33 +00:00

41 lines
1.2 KiB
PHP

<?php
use Boy132\Subdomains\Models\Subdomain;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('subdomains', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('record_type')->default('A');
$table->string('cloudflare_id')->nullable();
$table->unsignedInteger('domain_id');
$table->foreign('domain_id')->references('id')->on('cloudflare_domains')->cascadeOnDelete();
$table->unsignedInteger('server_id');
$table->foreign('server_id')->references('id')->on('servers')->cascadeOnDelete();
$table->timestamps();
$table->unique(['name', 'domain_id']);
});
}
public function down(): void
{
Subdomain::all()->each(function (Subdomain $subdomain) {
try {
$subdomain->delete();
} catch (Exception) {
}
});
Schema::dropIfExists('subdomains');
}
};