2025_04_04_101800_add_fields_discipline_table.php 889 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::table('disciplines', function (Blueprint $table) {
  15. if (!Schema::hasColumn('disciplines', 'code')) {
  16. $table->string('code')->nullable()->after('id');
  17. }
  18. if (!Schema::hasColumn('disciplines', 'sport')) {
  19. $table->string('sport')->nullable()->after('code');
  20. }
  21. });
  22. }
  23. /**
  24. * Reverse the migrations.
  25. *
  26. * @return void
  27. */
  28. public function down()
  29. {
  30. Schema::table('disciplines', function (Blueprint $table) {
  31. $table->dropColumn('code', 'sport');
  32. });
  33. }
  34. };