Files
mesreleves-php/database/migrations/2024_01_01_100100_create_sections_table.php
yann64 7609d35287 Initial scaffold : Laravel 12 + PostgreSQL + auth + domaine métier (étapes 1-5)
- Laravel 12 sur PHP 8.5, Breeze (Blade/Tailwind/Alpine.js)
- Docker Compose dev (PostgreSQL 18 + Redis) et prod (stack complète + nginx)
- Migrations et models : lieux, sections, dépôts, source_types/fields, sources, relevés
  - Colonne JSONB data sur releves avec colonnes générées indexées (nom, prenom, date_evenement)
  - Index GIN pour la recherche fulltext
- Enums : UserRole, SourceStatus (avec transitions), CalendarType, FieldType
- RoleMiddleware (alias `role`) + helpers isAdmin/isSectionManager sur User
- CRUD Lieux (arbre hiérarchique, calcul nom_long en cascade)
- CRUD admin : Sections (+ gestion membres), Dépôts, Types de sources (+ champs dynamiques, drag & drop)
- CRUD Sources : visibilité filtrée par rôle, assignation membres, workflow de statut

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-04 16:16:37 +02:00

35 lines
1.1 KiB
PHP

<?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('sections', function (Blueprint $table) {
$table->id();
$table->string('nom');
$table->foreignId('lieu_id')->nullable()->constrained('lieux')->nullOnDelete();
$table->string('adresse')->nullable();
$table->string('email_contact')->nullable();
$table->string('url')->nullable();
$table->timestamps();
});
Schema::create('section_user', function (Blueprint $table) {
$table->foreignId('section_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('role_in_section')->default('member'); // section_manager | member
$table->primary(['section_id', 'user_id']);
});
}
public function down(): void
{
Schema::dropIfExists('section_user');
Schema::dropIfExists('sections');
}
};