2018_04_15_165539_create_items_exchange_table.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateItemsExchangeTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('items_exchange', function (Blueprint $table) {
  15. $table->increments('id');
  16. $table->unsignedInteger('item_id');
  17. $table->unsignedInteger('item_offer_id');
  18. $table->tinyInteger('status')->default(null)->nullable();
  19. $table->timestamps();
  20. $table->foreign('item_id')
  21. ->references('id')->on('items')
  22. ->onDelete('cascade');
  23. $table->foreign('item_offer_id')
  24. ->references('id')->on('items')
  25. ->onDelete('cascade');
  26. });
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::table('items_exchange', function (Blueprint $table) {
  36. $table->dropForeign(['item_id']);
  37. $table->dropForeign(['item_offer_id']);
  38. });
  39. Schema::dropIfExists('items_exchange');
  40. }
  41. }