2021_01_06_114158_create_station_task_children2.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateStationTaskChildren2 extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('station_task_children', function (Blueprint $table) {
  15. $table->id();
  16. $table->bigInteger('station_task_id')->index();
  17. $table->string('station_taskable_type');
  18. $table->bigInteger('station_taskable_id');
  19. $table->index(['station_taskable_type','station_taskable_id'],'station_taskable_t_i');
  20. $table->timestamps();
  21. });
  22. Schema::table('station_tasks', function (Blueprint $table) {
  23. $table->dropColumn('station_taskable_type');
  24. $table->dropColumn('station_taskable_id');
  25. // $table->dropIndex('station_taskable_type');
  26. });
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::dropIfExists('station_task_children');
  36. Schema::table('station_tasks', function (Blueprint $table) {
  37. $table->string('station_taskable_type');
  38. $table->integer('station_taskable_id');
  39. $table->index(['station_taskable_id','station_taskable_id'],'station_taskable_type');
  40. });
  41. }
  42. }