2021_03_01_150232_create_delivery_appointments_table.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateDeliveryAppointmentsTable extends Migration
  6. {
  7. public $authorities = [
  8. "入库管理-盘收一体-客户预约",
  9. ];
  10. /**
  11. * Run the migrations.
  12. *
  13. * @return void
  14. */
  15. public function up()
  16. {
  17. Schema::create('delivery_appointments', function (Blueprint $table) {
  18. $table->id();
  19. $table->bigInteger("user_id")->nullable()->comment("操作用户");
  20. $table->bigInteger("owner_id")->index()->comment("外键货主");
  21. $table->string("procurement_number")->nullable()->comment("采购单号");
  22. $table->string("asn_number")->index()->nullable()->comment("ASN单号");
  23. $table->bigInteger("warehouse_id")->index()->comment("外键仓库");
  24. $table->decimal("tonne",8,2)->nullable()->comment("吨");
  25. $table->decimal("cubic_meter",8,2)->nullable()->comment("立方米");
  26. $table->integer("box_amount")->nullable()->comment("箱数");
  27. $table->decimal("capacity",10,2)->default(0)->comment("产能");
  28. $table->date("appointment_date")->index()->comment("预约时间");
  29. $table->tinyInteger("date_period")->default(0)->comment("时间段");
  30. $table->tinyInteger("status")->default(0)->comment("状态");
  31. $table->timestamps();
  32. });
  33. Schema::create('delivery_appointment_cars', function (Blueprint $table) {
  34. $table->id();
  35. $table->bigInteger("delivery_appointment_id")->index()->comment("外键预约");
  36. $table->string("license_plate_number")->nullable()->comment("车牌号");
  37. $table->string("car_id")->index()->nullable()->comment("外键车型");
  38. $table->string("driver_name",20)->nullable()->comment("驾驶员姓名");
  39. $table->string("driver_phone",30)->nullable()->comment("驾驶员电话");
  40. $table->string("appointment_number")->comment("预约号码");
  41. $table->tinyInteger("status")->default(0)->comment("状态");
  42. });
  43. Schema::create('delivery_appointment_details', function (Blueprint $table) {
  44. $table->id();
  45. $table->bigInteger("delivery_appointment_id")->index()->comment("外键预约");
  46. $table->bigInteger("commodity_id")->index()->nullable()->comment("外键商品");
  47. $table->string("bar_code")->nullable()->comment("条码");
  48. $table->string("name")->nullable()->comment("名称");
  49. $table->integer("amount")->comment("数量");
  50. });
  51. foreach ($this->authorities as $authority){
  52. \App\Authority::query()->firstOrCreate([
  53. "name"=>$authority
  54. ],[
  55. "name"=>$authority,
  56. "alias_name"=>$authority
  57. ]);
  58. }
  59. }
  60. /**
  61. * Reverse the migrations.
  62. *
  63. * @return void
  64. */
  65. public function down()
  66. {
  67. Schema::dropIfExists('delivery_appointments');
  68. Schema::dropIfExists('delivery_appointment_cars');
  69. Schema::dropIfExists('delivery_appointment_details');
  70. foreach ($this->authorities as $authority){
  71. \App\Authority::query()->where("name",$authority)->delete();
  72. }
  73. }
  74. }