2023_04_28_071852_create_goods_table.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration {
  6. /**
  7. * Run the migrations.
  8. *
  9. * @return void
  10. */
  11. public function up()
  12. {
  13. Schema::create('spec', function (Blueprint $table) {
  14. $table->id();
  15. $table->string("name")->default("");
  16. $table->string("extra", 2000)->default("");
  17. $table->unsignedInteger("index_weight")->default(0);
  18. $table->unsignedInteger("category_weight")->default(0);
  19. $table->unsignedInteger("search_weight")->default(0);
  20. $table->unsignedTinyInteger("is_custom")->default(0)->comment("是否自定义");
  21. $table->timestamps();
  22. $table->softDeletes();
  23. });
  24. Schema::create("spec_attr", function (Blueprint $t) {
  25. $t->id();
  26. $t->unsignedInteger("spec_id");
  27. $t->string("name");
  28. $t->timestamps();
  29. $t->softDeletes();
  30. });
  31. Schema::create('category', function (Blueprint $table) {
  32. $table->id();
  33. $table->string("name")->default("");
  34. $table->string("thumb")->default("");
  35. $table->unsignedTinyInteger("level")->default(0)->comment("层级");
  36. $table->unsignedInteger("parent_id")->default(0)->comment("上级分类ID");
  37. $table->integer("weight")->default(0)->comment("权重");
  38. $table->integer("index_weight")->default(0)->comment("推荐位权重");
  39. $table->integer("category_weight")->default(0)->comment("推荐位权重");
  40. $table->integer("search_weight")->default(0)->comment("搜索页权重");
  41. $table->timestamps();
  42. $table->softDeletes();
  43. });
  44. Schema::create('goods', function (Blueprint $table) {
  45. $table->id();
  46. $table->string("name")->default("");
  47. $table->string("image_list", 2000)->default("");
  48. $table->string("spec")->default("")->comment("商品的规格");
  49. $table->unsignedInteger("weight")->default(0);
  50. $table->text("desc_html")->nullable();
  51. $table->text("spec_attr_html")->nullable();
  52. $table->text("faq_html")->nullable();
  53. $table->unsignedTinyInteger("status")->default(1)->comment("1 上架 2下架");
  54. $table->unsignedInteger("view_total")->default(0)->comment("浏览量");
  55. $table->timestamps();
  56. $table->softDeletes();
  57. });
  58. Schema::create('goods_category_map', function (Blueprint $table) {
  59. $table->id();
  60. $table->unsignedInteger("goods_id")->default(0);
  61. $table->unsignedInteger("category_id")->default(0);
  62. $table->unsignedTinyInteger("is_public")->default(1)->comment("是否对普通会员展示");
  63. $table->timestamps();
  64. });
  65. Schema::create('goods_sku', function (Blueprint $table) {
  66. $table->id();
  67. $table->unsignedInteger("goods_id")->default(0);
  68. $table->string("sn")->default("")->comment("型号");
  69. $table->string("url_3d")->default("")->comment("3D的跳转地址");
  70. $table->string("spec_attr_list", 2000)->default("")->comment("规格数据");
  71. $table->unsignedTinyInteger("is_use")->default(1)->comment("是否使用");
  72. $table->timestamps();
  73. $table->softDeletes();
  74. $table->index("goods_id");
  75. });
  76. }
  77. /**
  78. * Reverse the migrations.
  79. *
  80. * @return void
  81. */
  82. public function down()
  83. {
  84. Schema::dropIfExists('spec');
  85. Schema::dropIfExists('spec_attr');
  86. Schema::dropIfExists('category');
  87. Schema::dropIfExists('goods');
  88. Schema::dropIfExists('goods_category_map');
  89. Schema::dropIfExists('goods_sku');
  90. }
  91. };