2018_04_21_182224_create_profiles_table.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateProfilesTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('profiles', function (Blueprint $table) {
  15. $table->increments('id');
  16. $table->unsignedInteger('user_id')->unique();
  17. $table->string('name');
  18. $table->string('surname');
  19. $table->enum('gender', ['m', 'f',null])->nullable();
  20. $table->string('country');
  21. $table->string('city');
  22. $table->integer('age');
  23. $table->string('hobby');
  24. $table->foreign('user_id')
  25. ->references('id')->on('users')
  26. ->onDelete('cascade');
  27. });
  28. }
  29. /**
  30. * Reverse the migrations.
  31. *
  32. * @return void
  33. */
  34. public function down()
  35. {
  36. Schema::table('profiles', function (Blueprint $table) {
  37. $table->dropForeign(['user_id']);
  38. });
  39. Schema::dropIfExists('profiles');
  40. }
  41. }