✨ 重新设计表结构
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateGroupsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('groups', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_unicode_ci';
|
||||
|
||||
$table->id();
|
||||
$table->string('name', 64)->comment('角色组名称');
|
||||
$table->boolean('is_default')->default(false)->comment('是否默认');
|
||||
$table->json('configs')->comment('组配置');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('groups');
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,24 @@ class CreateUsersTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_unicode_ci';
|
||||
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->foreignId('group_id')->nullable()->comment('角色组')->constrained('groups')->onDelete('set null');
|
||||
$table->string('name')->comment('姓名');
|
||||
$table->string('email')->unique()->comment('邮箱');
|
||||
$table->string('password')->comment('密码');
|
||||
$table->rememberToken();
|
||||
$table->boolean('is_adminer')->default(false)->comment('是否为管理员');
|
||||
$table->decimal('capacity', 20)->default(0)->comment('总容量(kb)');
|
||||
$table->json('configs')->comment('配置');
|
||||
$table->unsignedBigInteger('image_num')->default(0)->comment('图片数量');
|
||||
$table->unsignedBigInteger('album_num')->default(0)->comment('相册数量');
|
||||
$table->string('registered_ip')->default('')->comment('注册IP');
|
||||
$table->enum('status', ['normal', 'frozen'])->default('normal');
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateStrategiesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('strategies', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_unicode_ci';
|
||||
|
||||
$table->id();
|
||||
$table->foreignId('group_id')->comment('角色组')->constrained('groups')->onDelete('cascade');
|
||||
$table->enum('key', ['local'])->default('local');
|
||||
$table->string('name', 64)->comment('策略名称');
|
||||
$table->string('intro', 255)->default('')->comment('简介');
|
||||
$table->json('configs')->comment('策略配置');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('strategies');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAlbumsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('albums', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_unicode_ci';
|
||||
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->comment('用户')->constrained('users')->onDelete('cascade');
|
||||
$table->string('name', 64)->comment('名称');
|
||||
$table->string('intro')->default('')->comment('简介');
|
||||
$table->unsignedBigInteger('image_num')->default(0)->comment('图片数量');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('albums');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateImagesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('images', function (Blueprint $table) {
|
||||
$table->engine = 'InnoDB';
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_unicode_ci';
|
||||
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->nullable()->comment('用户')->constrained('users')->onDelete('set null');
|
||||
$table->foreignId('album_id')->nullable()->comment('相册')->constrained('albums')->onDelete('set null');
|
||||
$table->foreignId('strategy_id')->nullable()->comment('策略')->constrained('strategies')->onDelete('set null');
|
||||
$table->string('path')->comment('保存路径');
|
||||
$table->string('name')->comment('保存路径');
|
||||
$table->string('origin_name')->default('')->comment('原始名称');
|
||||
$table->string('alias_name')->default('')->comment('别名');
|
||||
$table->decimal('size')->default(0)->comment('图片大小(kb)');
|
||||
$table->string('mimetype', 32)->comment('文件类型');
|
||||
$table->string('md5', 32)->comment('文件MD5');
|
||||
$table->string('sha1')->comment('文件SHA1');
|
||||
$table->boolean('is_unhealthy')->default(false)->comment('是否为不健康的');
|
||||
$table->string('uploaded_ip')->default('')->comment('上传IP');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('images');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateConfigsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('configs', function (Blueprint $table) {
|
||||
$table->string('name', 32)->comment('配置名')->unique();
|
||||
$table->longText('value')->nullable()->comment('配置值');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('configs');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user