feat(website): add website type and extras models with migration and tests

This commit is contained in:
2026-07-29 14:09:47 -03:00
parent 7c9ebc6d4d
commit 04bf03fc2e
6 changed files with 345 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
<?php
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('website_type', function (Blueprint $table): void {
$table->id();
$table->string('codigo')->unique();
$table->string('nombre');
$table->timestamps();
});
Schema::table('tenants', function (Blueprint $table): void {
$table->string('website_type_code')->nullable();
$table->foreign('website_type_code')
->references('codigo')
->on('website_type')
->cascadeOnUpdate()
->nullOnDelete();
});
Schema::create('website_type_extras', function (Blueprint $table): void {
$table->id();
$table->foreignId('website_type')
->constrained('website_type')
->cascadeOnUpdate()
->cascadeOnDelete();
$table->string('nombre');
$table->text('descripcion');
$table->boolean('is_required')->default(false);
$table->json('config_schema');
$table->timestamps();
});
Schema::create('websites_extras', function (Blueprint $table): void {
$table->id();
$table->string('website_code');
$table->foreignId('website_type_extra_id')
->constrained('website_type_extras')
->cascadeOnUpdate()
->cascadeOnDelete();
$table->json('config');
$table->timestamps();
$table->foreign('website_code')
->references('codigo')
->on('tenants')
->cascadeOnUpdate()
->cascadeOnDelete();
});
}
public function down(): void
{
Schema::dropIfExists('websites_extras');
Schema::dropIfExists('website_type_extras');
Schema::table('tenants', function (Blueprint $table): void {
$table->dropForeign(['website_type_code']);
$table->dropColumn('website_type_code');
});
Schema::dropIfExists('website_type');
}
};