diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index c26b9f5..4ec42ab 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -16,7 +16,7 @@ class CreateUsersTable extends Migration Schema::defaultStringLength(191); Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('name'); + $table->string('name')->unique(); $table->string('email')->nullable()->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); @@ -25,7 +25,6 @@ class CreateUsersTable extends Migration $table->rememberToken(); $table->timestamps(); // 索引 - $table->unique('name'); }); } diff --git a/database/migrations/2022_07_26_061712_create_goods_types_table.php b/database/migrations/2022_07_26_061712_create_goods_types_table.php index 0ef0220..d923fa7 100644 --- a/database/migrations/2022_07_26_061712_create_goods_types_table.php +++ b/database/migrations/2022_07_26_061712_create_goods_types_table.php @@ -16,11 +16,10 @@ class CreateGoodsTypesTable extends Migration Schema::defaultStringLength(191); Schema::create('goods_types', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('name')->nullable(false); + $table->string('name')->unique(); $table->softDeletes(); $table->timestamps(); // 索引 - $table->unique('name'); }); } diff --git a/database/migrations/2022_07_26_085847_create_goods_brands_table.php b/database/migrations/2022_07_26_085847_create_goods_brands_table.php index 6e44c7c..482bd44 100644 --- a/database/migrations/2022_07_26_085847_create_goods_brands_table.php +++ b/database/migrations/2022_07_26_085847_create_goods_brands_table.php @@ -16,11 +16,10 @@ class CreateGoodsBrandsTable extends Migration Schema::defaultStringLength(191); Schema::create('goods_brands', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('name')->nullable(false); + $table->string('name')->unique(); $table->softDeletes(); $table->timestamps(); // 索引 - $table->unique('name'); }); } diff --git a/database/migrations/2022_07_26_090143_create_goods_table.php b/database/migrations/2022_07_26_090143_create_goods_table.php index 1fdf2da..71ad099 100644 --- a/database/migrations/2022_07_26_090143_create_goods_table.php +++ b/database/migrations/2022_07_26_090143_create_goods_table.php @@ -16,14 +16,13 @@ class CreateGoodsTable extends Migration Schema::defaultStringLength(191); Schema::create('goods', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('title')->nullable(false); + $table->string('title'); $table->string('img_url')->nullable()->comment('商品图片'); - $table->unsignedBigInteger('type_id')->nullable(false)->comment('商品种类id'); + $table->unsignedBigInteger('type_id')->comment('商品种类id'); $table->unsignedBigInteger('brand_id')->nullable()->comment('商品品牌id'); - $table->string('goods_code', 32)->nullable(false)->comment('商品编码'); + $table->string('goods_code', 32)->unique()->comment('商品编码'); $table->timestamps(); // 索引 - $table->unique('goods_code'); }); } diff --git a/database/migrations/2022_07_26_090150_create_goods_skus_table.php b/database/migrations/2022_07_26_090150_create_goods_skus_table.php index 468e37b..3b0f07a 100644 --- a/database/migrations/2022_07_26_090150_create_goods_skus_table.php +++ b/database/migrations/2022_07_26_090150_create_goods_skus_table.php @@ -16,9 +16,9 @@ class CreateGoodsSkusTable extends Migration Schema::defaultStringLength(191); Schema::create('goods_skus', function (Blueprint $table) { $table->bigIncrements('id'); - $table->unsignedBigInteger('goods_id')->nullable(false)->comment('商品id'); - $table->string('title')->nullable(false)->comment('商品规格'); - $table->string('sku_code', 32)->nullable(false)->comment('规格编码'); + $table->unsignedBigInteger('goods_id')->comment('商品id'); + $table->string('title')->comment('商品规格'); + $table->string('sku_code', 32)->comment('规格编码'); $table->unsignedTinyInteger('status')->default(0)->comment('规格状态(0-下架,1在售,2预警)'); $table->unsignedInteger('num')->default(0)->comment('总量'); $table->unsignedInteger('stock')->default(0)->comment('库存'); diff --git a/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php index 3b1c792..6d985ce 100644 --- a/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php +++ b/database/migrations/2022_07_26_103559_create_daily_stock_records_table.php @@ -15,8 +15,8 @@ class CreateDailyStockRecordsTable extends Migration { Schema::create('daily_stock_records', function (Blueprint $table) { $table->bigIncrements('id'); - $table->bigInteger('sku_id')->nullable(false); - $table->date('day')->nullable(false); + $table->bigInteger('sku_id'); + $table->date('day'); $table->unsignedInteger('arrived_today_num')->default(0)->comment('今日到货'); $table->unsignedInteger('loss_num')->default(0)->comment('损耗'); $table->unsignedInteger('inventory')->default(0)->comment('库存盘点'); diff --git a/database/migrations/2022_07_26_105818_create_logs_table.php b/database/migrations/2022_07_26_105818_create_logs_table.php index da9c3c2..aa67ef1 100644 --- a/database/migrations/2022_07_26_105818_create_logs_table.php +++ b/database/migrations/2022_07_26_105818_create_logs_table.php @@ -24,8 +24,9 @@ class CreateLogsTable extends Migration $table->text('after_update')->nullable()->comment('更新后数据'); $table->text('message')->nullable()->comment('备注信息'); $table->bigInteger('user_id')->comment('操作人id'); - $table->index(['target_type', 'target_id', 'target_field']); $table->timestamps(); + // 索引 + $table->index(['target_type', 'target_id', 'target_field']); }); } diff --git a/database/migrations/2022_07_28_095523_create_menus_table.php b/database/migrations/2022_07_28_095523_create_menus_table.php index 18bdaea..5019185 100644 --- a/database/migrations/2022_07_28_095523_create_menus_table.php +++ b/database/migrations/2022_07_28_095523_create_menus_table.php @@ -16,14 +16,13 @@ class CreateMenusTable extends Migration Schema::defaultStringLength(191); Schema::create('menus', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('code', 32)->nullable(false)->comment('菜单编码'); - $table->string('name', 32)->nullable(false)->comment('菜单名称'); + $table->string('code', 32)->unique()->comment('菜单编码'); + $table->string('name', 32)->comment('菜单名称'); $table->unsignedBigInteger('parent_id')->default(0); $table->unsignedInteger('seq')->default(0)->comment('排序序号'); $table->softDeletes(); $table->timestamps(); // 索引 - $table->unique('code'); }); } diff --git a/database/migrations/2022_08_02_022448_create_shops_table.php b/database/migrations/2022_08_02_022448_create_shops_table.php index 8364f24..e56de65 100644 --- a/database/migrations/2022_08_02_022448_create_shops_table.php +++ b/database/migrations/2022_08_02_022448_create_shops_table.php @@ -28,9 +28,10 @@ class CreateShopsTable extends Migration $table->unsignedInteger('refresh_token_expires_in')->nullable()->comment('refresh_token过期时间段,10表示10秒后过期'); $table->text('scope')->nullable()->comment('接口列表'); $table->text('pop_auth_token_create_response')->nullable()->comment('授权认证信息'); - $table->unsignedTinyInteger('status')->default(0)->comment('状态'); + $table->unsignedTinyInteger('status')->index()->default(0)->comment('状态'); $table->softDeletes(); $table->timestamps(); + //索引 }); } diff --git a/database/migrations/2022_08_05_093629_create_business_orders_table.php b/database/migrations/2022_08_05_093629_create_business_orders_table.php index d82f287..94ef6ef 100644 --- a/database/migrations/2022_08_05_093629_create_business_orders_table.php +++ b/database/migrations/2022_08_05_093629_create_business_orders_table.php @@ -55,6 +55,8 @@ class CreateBusinessOrdersTable extends Migration $table->string('transaction_id')->nullable(); $table->integer('verification_status')->nullable(); $table->timestamps(); + // 索引 + $table->unique(['shop_id', 'order_sn']); }); } diff --git a/database/migrations/2022_08_05_093658_create_business_order_items_table.php b/database/migrations/2022_08_05_093658_create_business_order_items_table.php index 0495831..e4bc837 100644 --- a/database/migrations/2022_08_05_093658_create_business_order_items_table.php +++ b/database/migrations/2022_08_05_093658_create_business_order_items_table.php @@ -39,6 +39,8 @@ class CreateBusinessOrderItemsTable extends Migration $table->string('thumb_url')->nullable(); $table->integer('verification_number')->nullable(); $table->timestamps(); + // 索引 + $table->index(['shop_id', 'business_order_id', 'goods_id', 'sku_id']); }); }