!26 代码优化

Merge pull request !26 from develop
This commit is contained in:
赵世界 2022-08-18 03:23:15 +00:00 committed by Gitee
commit ed1310b1e2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
11 changed files with 21 additions and 20 deletions

View File

@ -16,7 +16,7 @@ class CreateUsersTable extends Migration
Schema::defaultStringLength(191); Schema::defaultStringLength(191);
Schema::create('users', function (Blueprint $table) { Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('name'); $table->string('name')->unique();
$table->string('email')->nullable()->unique(); $table->string('email')->nullable()->unique();
$table->timestamp('email_verified_at')->nullable(); $table->timestamp('email_verified_at')->nullable();
$table->string('password'); $table->string('password');
@ -25,7 +25,6 @@ class CreateUsersTable extends Migration
$table->rememberToken(); $table->rememberToken();
$table->timestamps(); $table->timestamps();
// 索引 // 索引
$table->unique('name');
}); });
} }

View File

@ -16,11 +16,10 @@ class CreateGoodsTypesTable extends Migration
Schema::defaultStringLength(191); Schema::defaultStringLength(191);
Schema::create('goods_types', function (Blueprint $table) { Schema::create('goods_types', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('name')->nullable(false); $table->string('name')->unique();
$table->softDeletes(); $table->softDeletes();
$table->timestamps(); $table->timestamps();
// 索引 // 索引
$table->unique('name');
}); });
} }

View File

@ -16,11 +16,10 @@ class CreateGoodsBrandsTable extends Migration
Schema::defaultStringLength(191); Schema::defaultStringLength(191);
Schema::create('goods_brands', function (Blueprint $table) { Schema::create('goods_brands', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('name')->nullable(false); $table->string('name')->unique();
$table->softDeletes(); $table->softDeletes();
$table->timestamps(); $table->timestamps();
// 索引 // 索引
$table->unique('name');
}); });
} }

View File

@ -16,14 +16,13 @@ class CreateGoodsTable extends Migration
Schema::defaultStringLength(191); Schema::defaultStringLength(191);
Schema::create('goods', function (Blueprint $table) { Schema::create('goods', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('title')->nullable(false); $table->string('title');
$table->string('img_url')->nullable()->comment('商品图片'); $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->unsignedBigInteger('brand_id')->nullable()->comment('商品品牌id');
$table->string('goods_code', 32)->nullable(false)->comment('商品编码'); $table->string('goods_code', 32)->unique()->comment('商品编码');
$table->timestamps(); $table->timestamps();
// 索引 // 索引
$table->unique('goods_code');
}); });
} }

View File

@ -16,9 +16,9 @@ class CreateGoodsSkusTable extends Migration
Schema::defaultStringLength(191); Schema::defaultStringLength(191);
Schema::create('goods_skus', function (Blueprint $table) { Schema::create('goods_skus', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->unsignedBigInteger('goods_id')->nullable(false)->comment('商品id'); $table->unsignedBigInteger('goods_id')->comment('商品id');
$table->string('title')->nullable(false)->comment('商品规格'); $table->string('title')->comment('商品规格');
$table->string('sku_code', 32)->nullable(false)->comment('规格编码'); $table->string('sku_code', 32)->comment('规格编码');
$table->unsignedTinyInteger('status')->default(0)->comment('规格状态(0-下架,1在售,2预警)'); $table->unsignedTinyInteger('status')->default(0)->comment('规格状态(0-下架,1在售,2预警)');
$table->unsignedInteger('num')->default(0)->comment('总量'); $table->unsignedInteger('num')->default(0)->comment('总量');
$table->unsignedInteger('stock')->default(0)->comment('库存'); $table->unsignedInteger('stock')->default(0)->comment('库存');

View File

@ -15,8 +15,8 @@ class CreateDailyStockRecordsTable extends Migration
{ {
Schema::create('daily_stock_records', function (Blueprint $table) { Schema::create('daily_stock_records', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->bigInteger('sku_id')->nullable(false); $table->bigInteger('sku_id');
$table->date('day')->nullable(false); $table->date('day');
$table->unsignedInteger('arrived_today_num')->default(0)->comment('今日到货'); $table->unsignedInteger('arrived_today_num')->default(0)->comment('今日到货');
$table->unsignedInteger('loss_num')->default(0)->comment('损耗'); $table->unsignedInteger('loss_num')->default(0)->comment('损耗');
$table->unsignedInteger('inventory')->default(0)->comment('库存盘点'); $table->unsignedInteger('inventory')->default(0)->comment('库存盘点');

View File

@ -24,8 +24,9 @@ class CreateLogsTable extends Migration
$table->text('after_update')->nullable()->comment('更新后数据'); $table->text('after_update')->nullable()->comment('更新后数据');
$table->text('message')->nullable()->comment('备注信息'); $table->text('message')->nullable()->comment('备注信息');
$table->bigInteger('user_id')->comment('操作人id'); $table->bigInteger('user_id')->comment('操作人id');
$table->index(['target_type', 'target_id', 'target_field']);
$table->timestamps(); $table->timestamps();
// 索引
$table->index(['target_type', 'target_id', 'target_field']);
}); });
} }

View File

@ -16,14 +16,13 @@ class CreateMenusTable extends Migration
Schema::defaultStringLength(191); Schema::defaultStringLength(191);
Schema::create('menus', function (Blueprint $table) { Schema::create('menus', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('code', 32)->nullable(false)->comment('菜单编码'); $table->string('code', 32)->unique()->comment('菜单编码');
$table->string('name', 32)->nullable(false)->comment('菜单名称'); $table->string('name', 32)->comment('菜单名称');
$table->unsignedBigInteger('parent_id')->default(0); $table->unsignedBigInteger('parent_id')->default(0);
$table->unsignedInteger('seq')->default(0)->comment('排序序号'); $table->unsignedInteger('seq')->default(0)->comment('排序序号');
$table->softDeletes(); $table->softDeletes();
$table->timestamps(); $table->timestamps();
// 索引 // 索引
$table->unique('code');
}); });
} }

View File

@ -28,9 +28,10 @@ class CreateShopsTable extends Migration
$table->unsignedInteger('refresh_token_expires_in')->nullable()->comment('refresh_token过期时间段10表示10秒后过期'); $table->unsignedInteger('refresh_token_expires_in')->nullable()->comment('refresh_token过期时间段10表示10秒后过期');
$table->text('scope')->nullable()->comment('接口列表'); $table->text('scope')->nullable()->comment('接口列表');
$table->text('pop_auth_token_create_response')->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->softDeletes();
$table->timestamps(); $table->timestamps();
//索引
}); });
} }

View File

@ -55,6 +55,8 @@ class CreateBusinessOrdersTable extends Migration
$table->string('transaction_id')->nullable(); $table->string('transaction_id')->nullable();
$table->integer('verification_status')->nullable(); $table->integer('verification_status')->nullable();
$table->timestamps(); $table->timestamps();
// 索引
$table->unique(['shop_id', 'order_sn']);
}); });
} }

View File

@ -39,6 +39,8 @@ class CreateBusinessOrderItemsTable extends Migration
$table->string('thumb_url')->nullable(); $table->string('thumb_url')->nullable();
$table->integer('verification_number')->nullable(); $table->integer('verification_number')->nullable();
$table->timestamps(); $table->timestamps();
// 索引
$table->index(['shop_id', 'business_order_id', 'goods_id', 'sku_id']);
}); });
} }