Guest User

Untitled

a guest
Apr 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. use IlluminateSupportFacadesSchema;
  2. use IlluminateDatabaseSchemaBlueprint;
  3. use IlluminateDatabaseMigrationsMigration;
  4.  
  5. class CreateUsersTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::disableForeignKeyConstraints();
  15.  
  16. Schema::create('users', function (Blueprint $table) {
  17. $table->increments('id');
  18. $table->string('password');
  19. $table->string('first_name');
  20. $table->string('last_name');
  21. $table->integer('salutation_id')->unsigned()->nullable();
  22. $table->string('title')->default('Volunteer');
  23. $table->binary('profile_picture')->nullable();
  24. $table->string('address')->nullable();
  25. $table->string('city')->nullable();
  26. $table->integer('province_id')->unsigned()->nullable();
  27. $table->integer('country_id')->unsigned()->nullable();
  28. $table->string('postal_code', 9)->nullable();
  29. $table->string('email')->unique();
  30. $table->string('phone')->nullable();
  31. $table->integer('phone_preference_id')->unsigned()->nullable();
  32. $table->integer('contact_preference_id')->unsigned()->nullable();
  33. $table->boolean('casl_agreement')->default(0);
  34. $table->date('casl_agreementDate')->nullable();
  35. $table->boolean('is_admin')->default(0);
  36. $table->rememberToken();
  37. $table->timestamps();
  38. });
  39.  
  40. }
  41.  
  42. /**
  43. * Reverse the migrations.
  44. *
  45. * @return void
  46. */
  47. public function down()
  48. {
  49. Schema::drop('users');
  50. }
  51.  
  52. public function up()
  53. {
  54. Schema::table('users', function (Blueprint $table)
  55. {
  56. $table->foreign('salutation_id')->references('id')->on('salutations')->onDelete('set null');
  57. $table->foreign('province_id')->references('id')->on('provinces')->onDelete('set null');
  58. $table->foreign('country_id')->references('id')->on('countries')->onDelete('set null');
  59. $table->foreign('phone_preference_id')->references('id')->on('phone_preferences')->onDelete('set null');
  60. $table->foreign('contact_preference_id')->references('id')->on('contact_preferences')->onDelete('set null');
  61. });
  62. }
  63.  
  64. /**
  65. * Reverse the migrations.
  66. *
  67. * @return void
  68. */
  69. public function down()
  70. {
  71. Schema::table('users', function (Blueprint $table) {
  72.  
  73. });
  74. }
Add Comment
Please, Sign In to add comment