2021_01_06_114158_create_station_task_children2.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. });
  26. }
  27. /**
  28. * Reverse the migrations.
  29. *
  30. * @return void
  31. */
  32. public function down()
  33. {
  34. Schema::dropIfExists('station_task_children');
  35. Schema::table('station_tasks', function (Blueprint $table) {
  36. $table->string('station_taskable_type');
  37. $table->integer('station_taskable_id');
  38. $table->index(['station_taskable_id','station_taskable_id'],'station_taskable_type');
  39. });
  40. }
  41. }