|
|
@@ -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');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+};
|