2018_06_27_144134_create_users_profiles_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 CreateUsersProfilesTable extends Migration
  6. {
  7. protected $table = 'users_profiles';
  8. protected $table_users = TABLE_USERS;
  9. /**
  10. * Run the migrations.
  11. *
  12. * @return void
  13. */
  14. public function up()
  15. {
  16. Schema::create($this->table, function (Blueprint $table) {
  17. $table->integer('id')->comment('用户id')->unsigned()->unique();
  18. $table->char('sex', 1)->comment('性别,M-男,F-女')->nullable();
  19. $table->date('birthday')->comment('生日')->nullable();
  20. $table->string('residence', 50)->comment('居住地')->nullable();
  21. $table->string('education', 10)->comment('教育程度')->nullable();
  22. $table->string('school', 50)->comment('就读学校')->nullable();
  23. $table->string('class', 20)->comment('就读班级')->nullable();
  24. $table->timestamps();
  25. $table->foreign('id')->references('id')->on($this->table_users);
  26. });
  27. DB::statement("ALTER TABLE ".$this->table." comment'会员资料表'");
  28. }
  29. /**
  30. * Reverse the migrations.
  31. *
  32. * @return void
  33. */
  34. public function down()
  35. {
  36. Schema::dropIfExists($this->table);
  37. }
  38. }