2017_06_11_073305_create_address_table.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateAddressTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('addresses', function (Blueprint $table) {
  15. $table->increments('id');
  16. $table->string('alias');
  17. $table->string('address_1');
  18. $table->string('address_2')->nullable();
  19. $table->string('zip')->nullable();
  20. $table->string('state_code')->nullable();
  21. $table->string('city')->nullable();
  22. $table->integer('province_id')->nullable();
  23. $table->integer('country_id')->unsigned()->index();
  24. $table->foreign('country_id')->references('id')->on('countries');
  25. $table->integer('customer_id')->unsigned()->index();
  26. $table->foreign('customer_id')->references('id')->on('customers');
  27. $table->integer('status')->default(0);
  28. $table->softDeletes();
  29. $table->timestamps();
  30. });
  31. }
  32. /**
  33. * Reverse the migrations.
  34. *
  35. * @return void
  36. */
  37. public function down()
  38. {
  39. Schema::dropIfExists('addresses');
  40. }
  41. }