Prechádzať zdrojové kódy

feat(class): migration de campos de aula e justificativa de presença

Adiciona class_package_unit_id, instructor e room na tabela classes
e a flag justified em class_attendances.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ebagabee 1 mesiac pred
rodič
commit
ab7b5a2f56

+ 54 - 0
database/migrations/2026_06_23_000001_add_fields_to_classes_and_attendances.php

@@ -0,0 +1,54 @@
+<?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('classes', function (Blueprint $table) {
+            if (!Schema::hasColumn('classes', 'class_package_unit_id')) {
+                $table->foreignId('class_package_unit_id')
+                    ->nullable()
+                    ->after('unit_id')
+                    ->constrained('class_package_units')
+                    ->nullOnDelete();
+            }
+            if (!Schema::hasColumn('classes', 'instructor')) {
+                $table->string('instructor')->nullable()->after('title');
+            }
+            if (!Schema::hasColumn('classes', 'room')) {
+                $table->string('room')->nullable()->after('instructor');
+            }
+        });
+
+        Schema::table('class_attendances', function (Blueprint $table) {
+            if (!Schema::hasColumn('class_attendances', 'justified')) {
+                $table->boolean('justified')->default(false)->after('in_class');
+            }
+        });
+    }
+
+    public function down(): void
+    {
+        Schema::table('classes', function (Blueprint $table) {
+            if (Schema::hasColumn('classes', 'class_package_unit_id')) {
+                $table->dropConstrainedForeignId('class_package_unit_id');
+            }
+            if (Schema::hasColumn('classes', 'instructor')) {
+                $table->dropColumn('instructor');
+            }
+            if (Schema::hasColumn('classes', 'room')) {
+                $table->dropColumn('room');
+            }
+        });
+
+        Schema::table('class_attendances', function (Blueprint $table) {
+            if (Schema::hasColumn('class_attendances', 'justified')) {
+                $table->dropColumn('justified');
+            }
+        });
+    }
+};