This commit is contained in:
Laucha1312
2026-06-04 15:15:23 -03:00
parent 0841794c50
commit 90c5f85512
167 changed files with 15870 additions and 0 deletions
@@ -0,0 +1,49 @@
<?php
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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?php
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('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,59 @@
<?php
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('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue');
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
$table->index(['queue', 'reserved_at', 'available_at']);
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('carousel_items', function (Blueprint $table) {
$table->id();
$table->string('titulo')->nullable();
$table->string('subtitulo')->nullable();
$table->string('boton_texto')->nullable();
$table->string('boton_enlace')->nullable();
$table->string('imagen');
$table->integer('orden')->default(0);
$table->boolean('activo')->default(true);
$table->timestamps();
});
// Insert default items to preserve the first 3 original items
DB::table('carousel_items')->insert([
[
'titulo' => 'Bienvenido a OnAPB',
'subtitulo' => 'La nueva forma de vivir el básquet en Paraná',
'boton_texto' => 'Ver partidos',
'boton_enlace' => '/eventos',
'imagen' => 'hero1.jpeg',
'orden' => 1,
'activo' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'titulo' => 'El basquet en tus manos',
'subtitulo' => 'Seguilo como nunca antes',
'boton_texto' => 'Unite',
'boton_enlace' => '/asociate',
'imagen' => 'hero2.jpg',
'orden' => 2,
'activo' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'titulo' => 'Sumate a la comunidad',
'subtitulo' => 'Asociate y disfrutá beneficios exclusivos',
'boton_texto' => 'Lugares',
'boton_enlace' => '/promos',
'imagen' => 'hero3.jpg',
'orden' => 3,
'activo' => true,
'created_at' => now(),
'updated_at' => now(),
]
]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('carousel_items');
}
};
@@ -0,0 +1,41 @@
<?php
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::table('admin_users', function (Blueprint $table) {
if (!Schema::hasColumn('admin_users', 'id_club')) {
$table->integer('id_club')->nullable()->after('password');
} else {
// Si la columna ya se creó en error en un intento anterior pero mal tipada
$table->integer('id_club')->nullable()->change();
}
// Agregamos la constrain después de asegurarnos de su tipo
});
Schema::table('admin_users', function (Blueprint $table) {
// Intentar dropear llave si existe para evitar error por si acaso no va,
// pero como falló en el fk, mejor tratamos de crearla:
$table->foreign('id_club')->references('id_club')->on('clubes')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('admin_users', function (Blueprint $table) {
$table->dropForeign(['id_club']);
$table->dropColumn('id_club');
});
}
};
@@ -0,0 +1,31 @@
<?php
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('categorias', function (Blueprint $table) {
$table->id('id_categoria');
$table->string('nombre');
$table->integer('edad_min');
$table->integer('edad_max');
$table->string('genero')->nullable(); // M, F, Mixto...
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('categorias');
}
};
@@ -0,0 +1,37 @@
<?php
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('pases', function (Blueprint $table) {
$table->id('id_pase');
$table->char('id_jugador', 36)->nullable();
$table->integer('id_club_origen')->nullable();
$table->integer('id_club_destino')->nullable();
$table->string('estado')->default('Pendiente'); // Pendiente, Aprobado, Rechazado
// Si la FK en jugadores es de tipo uuid, usamos char(36)
$table->foreign('id_jugador')->references('id_jugador')->on('jugadores')->onDelete('cascade');
$table->foreign('id_club_origen')->references('id_club')->on('clubes')->onDelete('cascade');
$table->foreign('id_club_destino')->references('id_club')->on('clubes')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pases');
}
};
@@ -0,0 +1,22 @@
<?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::table('eventos', function (Blueprint $table) {
$table->integer('limite_qr_jugador')->default(3)->after('precio');
});
}
public function down(): void
{
Schema::table('eventos', function (Blueprint $table) {
$table->dropColumn('limite_qr_jugador');
});
}
};
@@ -0,0 +1,23 @@
<?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::table('clubes', function (Blueprint $table) {
$table->string('qr_background')->nullable();
$table->string('qr_color_texto')->default('#000000');
});
}
public function down(): void
{
Schema::table('clubes', function (Blueprint $table) {
$table->dropColumn(['qr_background', 'qr_color_texto']);
});
}
};
@@ -0,0 +1,22 @@
<?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::table('categorias', function (Blueprint $table) {
$table->boolean('es_libre')->default(false);
});
}
public function down(): void
{
Schema::table('categorias', function (Blueprint $table) {
$table->dropColumn('es_libre');
});
}
};
@@ -0,0 +1,30 @@
<?php
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('configuraciones', function (Blueprint $table) {
$table->id();
$table->string('clave')->unique();
$table->text('valor')->nullable();
$table->string('descripcion')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('configuraciones');
}
};
@@ -0,0 +1,74 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// 1. Remove foreign keys if they exist (using identified names)
try {
Schema::table('jugador_equipo', function (Blueprint $table) {
// Try standard name and then the ibfk one
$table->dropForeign('jugador_equipo_id_jugador_foreign');
});
} catch (\Exception $e) {}
try {
// Drop confirmed name
DB::statement('ALTER TABLE jugador_equipo DROP FOREIGN KEY jugador_equipo_ibfk_1');
} catch (\Exception $e) {}
try {
DB::statement('ALTER TABLE qr_codes DROP FOREIGN KEY qr_codes_ibfk_2');
} catch (\Exception $e) {}
// 2. Increase the length of id_jugador in the main table
Schema::table('jugadores', function (Blueprint $table) {
$table->string('id_jugador', 20)->change();
});
// 3. Increase the length in referencing tables
Schema::table('pases', function (Blueprint $table) {
$table->string('id_jugador', 20)->change();
});
Schema::table('jugador_equipo', function (Blueprint $table) {
$table->string('id_jugador', 20)->change();
});
Schema::table('qr_codes', function (Blueprint $table) {
$table->string('id_jugador', 20)->nullable()->change();
});
// 4. Restore foreign keys (Laravel will pick names)
Schema::table('pases', function (Blueprint $table) {
// Check if column exists and is not already a FK
try {
$table->foreign('id_jugador')->references('id_jugador')->on('jugadores')->onDelete('cascade');
} catch (\Exception $e) {}
});
Schema::table('jugador_equipo', function (Blueprint $table) {
$table->foreign('id_jugador')->references('id_jugador')->on('jugadores')->onDelete('cascade');
});
Schema::table('qr_codes', function (Blueprint $table) {
$table->foreign('id_jugador')->references('id_jugador')->on('jugadores')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// No revert needed for length increase
}
};
@@ -0,0 +1,32 @@
<?php
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::table('clubes', function (Blueprint $table) {
if (!Schema::hasColumn('clubes', 'imagen')) {
$table->string('imagen')->nullable()->after('nombre');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('clubes', function (Blueprint $table) {
if (Schema::hasColumn('clubes', 'imagen')) {
$table->dropColumn('imagen');
}
});
}
};
@@ -0,0 +1,32 @@
<?php
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('sponsors', function (Blueprint $blueprint) {
$blueprint->id('id_sponsor');
$blueprint->string('nombre', 100);
$blueprint->string('imagen', 255);
$blueprint->string('url', 255)->nullable();
$blueprint->boolean('activo')->default(true);
$blueprint->integer('orden')->default(0);
$blueprint->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sponsors');
}
};
@@ -0,0 +1,30 @@
<?php
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('torneos', function (Blueprint $table) {
$table->id();
$table->string('nombre');
$table->date('fecha_inicio')->nullable();
$table->date('fecha_fin')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('torneos');
}
};
@@ -0,0 +1,30 @@
<?php
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('torneo_equipo', function (Blueprint $table) {
$table->id();
$table->foreignId('id_torneo')->constrained('torneos')->onDelete('cascade');
$table->unsignedBigInteger('id_equipo');
$table->foreign('id_equipo')->references('id_equipo')->on('equipos')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('torneo_equipo');
}
};
@@ -0,0 +1,30 @@
<?php
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::table('eventos', function (Blueprint $table) {
$table->unsignedBigInteger('id_torneo')->nullable()->after('id_evento');
$table->foreign('id_torneo')->references('id')->on('torneos')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('eventos', function (Blueprint $table) {
$table->dropForeign(['id_torneo']);
$table->dropColumn('id_torneo');
});
}
};
@@ -0,0 +1,29 @@
<?php
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::table('eventos', function (Blueprint $col) {
$col->integer('marcador_local')->nullable()->default(0)->after('id_equipo_visitante');
$col->integer('marcador_visitante')->nullable()->default(0)->after('marcador_local');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('eventos', function (Blueprint $col) {
$col->dropColumn(['marcador_local', 'marcador_visitante']);
});
}
};
@@ -0,0 +1,37 @@
<?php
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('evento_jugador', function (Blueprint $table) {
$table->id();
$table->string('id_evento');
$table->string('id_jugador');
$table->integer('puntos')->default(0);
$table->integer('faltas')->default(0);
$table->timestamps();
$table->foreign('id_evento')->references('id_evento')->on('eventos')->onDelete('cascade');
$table->foreign('id_jugador')->references('id_jugador')->on('jugadores')->onDelete('cascade');
// Un jugador solo puede tener un registro de puntos por evento
$table->unique(['id_evento', 'id_jugador']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('evento_jugador');
}
};
@@ -0,0 +1,28 @@
<?php
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::table('torneo_equipo', function (Blueprint $table) {
$table->string('grupo')->nullable()->after('id_equipo');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('torneo_equipo', function (Blueprint $table) {
$table->dropColumn('grupo');
});
}
};
@@ -0,0 +1,52 @@
<?php
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::table('jugadores', function (Blueprint $table) {
$table->softDeletes();
});
Schema::table('clubes', function (Blueprint $table) {
$table->softDeletes();
});
Schema::table('equipos', function (Blueprint $table) {
$table->softDeletes();
});
Schema::table('eventos', function (Blueprint $table) {
$table->softDeletes();
});
Schema::table('torneos', function (Blueprint $table) {
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('jugadores', function (Blueprint $table) {
$table->dropSoftDeletes();
});
Schema::table('clubes', function (Blueprint $table) {
$table->dropSoftDeletes();
});
Schema::table('equipos', function (Blueprint $table) {
$table->dropSoftDeletes();
});
Schema::table('eventos', function (Blueprint $table) {
$table->dropSoftDeletes();
});
Schema::table('torneos', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
};
@@ -0,0 +1,31 @@
<?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('notificaciones', function (Blueprint $table) {
$table->id();
$table->enum('tipo_destinatario', ['jugador', 'aficionado'])->index();
$table->string('id_destinatario'); // jugador.id_jugador o aficionado.id_aficionado
$table->enum('tipo', ['partido', 'resultado', 'sistema', 'seguimiento'])->default('sistema');
$table->string('titulo');
$table->text('mensaje');
$table->string('url_accion')->nullable();
$table->boolean('leida')->default(false);
$table->boolean('enviada_email')->default(false);
$table->timestamp('creada_en')->useCurrent();
$table->index(['tipo_destinatario', 'id_destinatario', 'leida']);
});
}
public function down(): void
{
Schema::dropIfExists('notificaciones');
}
};
@@ -0,0 +1,27 @@
<?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('equipo_seguimiento', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('id_equipo');
$table->enum('tipo_usuario', ['jugador', 'aficionado']);
$table->string('id_usuario'); // id_jugador (string) o id_aficionado (int as string)
$table->timestamp('created_at')->useCurrent();
$table->unique(['id_equipo', 'tipo_usuario', 'id_usuario'], 'uq_seguimiento');
$table->index(['tipo_usuario', 'id_usuario']);
});
}
public function down(): void
{
Schema::dropIfExists('equipo_seguimiento');
}
};
@@ -0,0 +1,29 @@
<?php
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::table('eventos', function (Blueprint $table) {
$table->integer('fase')->default(0)->after('id_torneo')->comment('0=Regular, 1=Cuartos, 2=Semis, 3=Final');
$table->integer('numero_partido_bracket')->nullable()->after('fase');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('eventos', function (Blueprint $table) {
$table->dropColumn(['fase', 'numero_partido_bracket']);
});
}
};
@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// 1. Corregir tipo de dato en qr_codes (ENUM -> VARCHAR)
// Usamos DB::statement por compatibilidad con MariaDB/MySQL sin necesidad de dbal
DB::statement("ALTER TABLE qr_codes MODIFY tipo_qr VARCHAR(50) NOT NULL");
// 2. Corregir marcadores en eventos (0 -> NULL)
DB::statement("ALTER TABLE eventos MODIFY marcador_local INT NULL DEFAULT NULL");
DB::statement("ALTER TABLE eventos MODIFY marcador_visitante INT NULL DEFAULT NULL");
// 3. Limpieza de datos: partidos con 0-0 que deberían ser Pendientes (NULL)
// Solo afectamos registros donde ambos son 0 para no romper resultados reales (aunque raros en básquet)
DB::table('eventos')
->where('marcador_local', 0)
->where('marcador_visitante', 0)
->update([
'marcador_local' => null,
'marcador_visitante' => null
]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Volver a ENUM y Default 0
DB::statement("ALTER TABLE qr_codes MODIFY tipo_qr ENUM('invitado', 'publico') NOT NULL");
DB::statement("ALTER TABLE eventos MODIFY marcador_local INT NOT NULL DEFAULT 0");
DB::statement("ALTER TABLE eventos MODIFY marcador_visitante INT NOT NULL DEFAULT 0");
}
};
@@ -0,0 +1,34 @@
<?php
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('push_subscriptions', function (Blueprint $table) {
$table->id();
$table->string('id_usuario'); // ID del jugador o aficionado
$table->string('tipo_usuario'); // 'jugador' o 'aficionado'
$table->text('endpoint'); // URL de suscripción del navegador
$table->string('p256dh'); // Clave pública del navegador
$table->string('auth'); // Token de autenticación del navegador
$table->timestamps();
$table->index(['id_usuario', 'tipo_usuario']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('push_subscriptions');
}
};
@@ -0,0 +1,46 @@
<?php
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::table('noticias', function (Blueprint $table) {
// Añadimos categoria si no existe
if (!Schema::hasColumn('noticias', 'categoria')) {
$table->string('categoria', 50)->nullable()->after('contenido');
}
// Añadimos id_torneo si no existe
if (!Schema::hasColumn('noticias', 'id_torneo')) {
$table->unsignedBigInteger('id_torneo')->nullable()->after('categoria');
// Intentamos añadir la clave foránea solo si la tabla torneos existe (por seguridad)
if (Schema::hasTable('torneos')) {
$table->foreign('id_torneo')->references('id')->on('torneos')->onDelete('set null');
}
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('noticias', function (Blueprint $table) {
if (Schema::hasColumn('noticias', 'id_torneo')) {
$table->dropForeign(['id_torneo']);
$table->dropColumn('id_torneo');
}
if (Schema::hasColumn('noticias', 'categoria')) {
$table->dropColumn('categoria');
}
});
}
};
@@ -0,0 +1,31 @@
<?php
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('agent_threads', function (Blueprint $table) {
$table->id();
$table->string('thread_id', 36)->unique();
$table->integer('admin_id');
$table->json('messages');
$table->timestamps();
$table->timestamp('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('agent_threads');
}
};
@@ -0,0 +1,22 @@
<?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::table('clubes', function (Blueprint $table) {
$table->boolean('es_seleccion')->default(false)->after('nombre');
});
}
public function down(): void
{
Schema::table('clubes', function (Blueprint $table) {
$table->dropColumn('es_seleccion');
});
}
};
@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Agrega created_at y updated_at (nullable) a clubes, equipos y eventos
* para habilitar el orden "recién creados/editados primero" en /admin/*.
*
* Backfill: NULL en registros existentes. El orderBy usa COALESCE para
* que los registros viejos caigan al fallback (id_xxx DESC) hasta que
* sean editados, momento en el cual reciben timestamps y saltan al tope.
*/
public function up(): void
{
foreach (['clubes', 'equipos', 'eventos'] as $tabla) {
Schema::table($tabla, function (Blueprint $table) {
if (!Schema::hasColumn($table->getTable(), 'created_at')) {
$table->timestamp('created_at')->nullable();
}
if (!Schema::hasColumn($table->getTable(), 'updated_at')) {
$table->timestamp('updated_at')->nullable();
}
});
}
}
public function down(): void
{
foreach (['clubes', 'equipos', 'eventos'] as $tabla) {
Schema::table($tabla, function (Blueprint $table) {
if (Schema::hasColumn($table->getTable(), 'updated_at')) {
$table->dropColumn('updated_at');
}
if (Schema::hasColumn($table->getTable(), 'created_at')) {
$table->dropColumn('created_at');
}
});
}
}
};