博客颜色数据库迁移构建

This commit is contained in:
筱锋xiao_lfeng 2023-06-16 16:30:49 +08:00
parent 02f9675b00
commit 2516de70d6
2 changed files with 116 additions and 0 deletions

View File

@ -0,0 +1,39 @@
<?php
/*
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
* 开发开源遵循 MIT 许可,若需商用请联系开发者
* https://www.x-lf.com/
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBlogColorTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('blog_color', function (Blueprint $table) {
$table->id();
$table->boolean('onlyAdminUse')->default(0)->comment('只允许管理员使用');
$table->string('colorLightType')->default('text-gray-500')->comment('颜色ID');
$table->string('colorDarkType')->default('dark:text-gray-800')->comment('暗色颜色ID');
$table->string('comment')->nullable()->comment('备注');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('blog_color');
}
}

View File

@ -0,0 +1,77 @@
<?php
/*
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
* 开发开源遵循 MIT 许可,若需商用请联系开发者
* https://www.x-lf.com/
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class UpdateBlogColorTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('blog_color', function (Blueprint $table) {
DB::table('blog_color')->insert([
'colorLightType' => 'text-gray-500',
'colorDarkType' => 'dark:text-gray-800',
'comment' => '灰色'
]);
DB::table('blog_color')->insert([
'colorLightType' => 'text-blue-500',
'colorDarkType' => 'dark:text-blue-800',
'comment' => '蓝色'
]);
DB::table('blog_color')->insert([
'colorLightType' => 'text-indigo-500',
'colorDarkType' => 'dark:text-indigo-800',
'comment' => '靛青色'
]);
DB::table('blog_color')->insert([
'colorLightType' => 'text-purple-500',
'colorDarkType' => 'dark:text-purple-800',
'comment' => '紫色'
]);
DB::table('blog_color')->insert([
'colorLightType' => 'text-pink-500',
'colorDarkType' => 'dark:text-pink-800',
'comment' => '粉色'
]);
DB::table('blog_color')->insert([
'colorLightType' => 'text-green-500',
'colorDarkType' => 'dark:text-green-800',
'comment' => '绿色'
]);
DB::table('blog_color')->insert([
'colorLightType' => 'text-yellow-500',
'colorDarkType' => 'dark:text-yellow-800',
'comment' => '蓝色'
]);
DB::table('blog_color')->insert([
'colorLightType' => 'text-red-500',
'colorDarkType' => 'dark:text-red-800',
'comment' => '红色'
]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('blog_color', function (Blueprint $table) {
//
});
}
}