2020_12_21_185328_create_flights_table.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateFlightsTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('flights', function (Blueprint $table) {
  15. $table->id();
  16. $table->bigInteger('plane_id')->unsigned();
  17. $table->bigInteger('route_id')->unsigned();
  18. $table->foreign('plane_id')->references('id')->on('planes')->onDelete('cascade');
  19. $table->foreign('route_id')->references('id')->on('routes')->onDelete('cascade');
  20. $table->datetime('departure');
  21. $table->datetime('arrival');
  22. $table->enum('status', ['in_flight', 'awaiting_flight', 'arrived', 'canceled']);
  23. $table->timestamps();
  24. });
  25. }
  26. /**
  27. * Reverse the migrations.
  28. *
  29. * @return void
  30. */
  31. public function down()
  32. {
  33. Schema::dropIfExists('flights');
  34. }
  35. }