M1: 数据模型 + sablog:import 脚本(MySQL 8 验证通过,不迁移 trackback 等过时功能)

This commit is contained in:
ak
2026-08-11 17:40:13 +08:00
parent 8d526a8cfd
commit f16bb75538
17 changed files with 1010 additions and 13 deletions
@@ -16,7 +16,7 @@ return new class extends Migration
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('password')->nullable();
$table->rememberToken();
$table->timestamps();
});
@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('name', 50);
$table->string('slug', 120)->nullable()->unique();
$table->tinyInteger('display_order')->default(0);
$table->unsignedInteger('post_count')->default(0);
$table->timestamps();
});
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->string('title');
$table->string('slug', 255)->nullable()->unique();
$table->text('excerpt')->nullable();
$table->longText('content');
$table->string('keywords', 255)->nullable();
$table->string('status', 20)->default('published')->index();
$table->boolean('is_sticky')->default(false);
$table->boolean('close_comment')->default(false);
$table->string('read_password', 255)->nullable();
$table->unsignedBigInteger('views')->default(0);
$table->unsignedInteger('comment_count')->default(0);
$table->json('meta')->nullable();
$table->timestamp('published_at')->nullable()->index();
$table->timestamps();
$table->index(['status', 'published_at']);
});
}
public function down(): void
{
Schema::dropIfExists('posts');
Schema::dropIfExists('categories');
}
};
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('comments', function (Blueprint $table) {
$table->id();
$table->foreignId('post_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->string('author_name', 50);
$table->string('author_email', 255)->nullable();
$table->string('author_url', 255)->nullable();
$table->mediumText('content');
$table->string('ip', 64)->nullable();
$table->string('status', 20)->default('pending')->index();
$table->json('ai_review')->nullable();
$table->timestamp('created_at')->useCurrent();
$table->index(['post_id', 'status']);
});
}
public function down(): void
{
Schema::dropIfExists('comments');
}
};
@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('links', function (Blueprint $table) {
$table->id();
$table->string('name', 100);
$table->string('url', 255);
$table->string('note', 255)->nullable();
$table->tinyInteger('display_order')->default(0);
$table->boolean('visible')->default(true);
$table->timestamps();
});
Schema::create('settings', function (Blueprint $table) {
$table->string('key')->primary();
$table->text('value');
$table->timestamps();
});
Schema::create('plugin_records', function (Blueprint $table) {
$table->id();
$table->string('vendor', 60);
$table->string('name', 60);
$table->string('version', 40)->nullable();
$table->boolean('enabled')->default(true);
$table->timestamps();
$table->unique(['vendor', 'name']);
});
}
public function down(): void
{
Schema::dropIfExists('plugin_records');
Schema::dropIfExists('settings');
Schema::dropIfExists('links');
}
};
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('legacy_md5', 32)->nullable()->index();
$table->string('url', 255)->nullable();
$table->unsignedInteger('logincount')->default(0);
$table->string('loginip', 64)->nullable();
$table->string('regip', 64)->nullable();
$table->timestamp('logintime')->nullable();
$table->timestamp('lastpost_at')->nullable();
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn([
'legacy_md5', 'url', 'logincount', 'loginip', 'regip', 'logintime', 'lastpost_at',
]);
});
}
};