Initial baseline: LaraBlog core with plugin commerce surface.

Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
This commit is contained in:
ak
2026-08-12 01:15:38 +08:00
commit 263b98b218
337 changed files with 31393 additions and 0 deletions
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,24 @@
<?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(config('settings.repositories.database.table') ?? 'settings', function (Blueprint $table): void {
$table->id();
$table->string('group');
$table->string('name');
$table->boolean('locked')->default(false);
$table->json('payload');
$table->timestamps();
$table->unique(['group', 'name']);
});
}
};
@@ -0,0 +1,134 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$teams = config('permission.teams');
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), Exception::class, 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
// $table->engine('InnoDB');
$table->bigIncrements('id'); // permission id
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
// $table->engine('InnoDB');
$table->bigIncrements('id'); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
}
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
$table->timestamps();
if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
$table->unsignedBigInteger($pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
$table->unsignedBigInteger($pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
} else {
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
}
});
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
$table->unsignedBigInteger($pivotPermission);
$table->unsignedBigInteger($pivotRole);
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$tableNames = config('permission.table_names');
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
Schema::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
};
@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('log_name')->nullable();
$table->text('description');
$table->nullableMorphs('subject', 'subject');
$table->nullableMorphs('causer', 'causer');
$table->json('properties')->nullable();
$table->timestamps();
$table->index('log_name');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
}
}
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddEventColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->string('event')->nullable()->after('subject_type');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('event');
});
}
}
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddBatchUuidColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->uuid('batch_uuid')->nullable()->after('properties');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('batch_uuid');
});
}
}
@@ -0,0 +1,158 @@
<?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');
$table->unsignedInteger('display_order')->default(0);
$table->unsignedInteger('articles_count')->default(0);
$table->timestamps();
});
Schema::create('articles', function (Blueprint $table) {
$table->id();
$table->foreignId('category_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('title');
$table->longText('content');
$table->string('content_format', 16)->default('html');
$table->string('description')->nullable();
$table->string('keywords')->nullable();
$table->timestamp('published_at')->nullable();
$table->unsignedBigInteger('views')->default(0);
$table->unsignedInteger('comments_count')->default(0);
$table->string('slug')->nullable()->unique();
$table->boolean('stick')->default(false);
$table->boolean('visible')->default(true);
$table->boolean('close_comment')->default(false);
$table->string('read_password')->nullable();
$table->text('ai_summary')->nullable();
$table->json('ai_suggestions')->nullable();
$table->json('legacy_attachments')->nullable();
$table->timestamps();
$table->index(['visible', 'published_at']);
$table->index('category_id');
});
Schema::create('comments', function (Blueprint $table) {
$table->id();
$table->foreignId('article_id')->constrained()->cascadeOnDelete();
$table->string('author');
$table->string('url')->nullable();
$table->text('content');
$table->string('ip', 45)->nullable();
$table->string('moderation_status')->default('pending');
$table->timestamp('published_at')->nullable();
$table->timestamps();
});
Schema::create('tags', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->unsignedInteger('use_count')->default(0);
$table->timestamps();
});
Schema::create('article_tag', function (Blueprint $table) {
$table->foreignId('article_id')->constrained()->cascadeOnDelete();
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
$table->unique(['article_id', 'tag_id']);
});
Schema::create('attachments', function (Blueprint $table) {
$table->id();
$table->foreignId('article_id')->nullable()->constrained()->nullOnDelete();
$table->string('disk')->default('attachments');
$table->string('path');
$table->string('thumb_path')->nullable();
$table->string('filename');
$table->string('mime')->nullable();
$table->unsignedBigInteger('size')->default(0);
$table->string('checksum')->nullable();
$table->string('visibility')->default('public');
$table->string('legacy_filepath')->nullable();
$table->timestamp('synced_at')->nullable();
$table->unsignedBigInteger('downloads')->default(0);
$table->timestamps();
$table->index('legacy_filepath');
});
Schema::create('links', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('url');
$table->text('note')->nullable();
$table->unsignedInteger('display_order')->default(0);
$table->boolean('visible')->default(true);
$table->timestamps();
});
Schema::create('stylevars', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('value')->nullable();
$table->boolean('visible')->default(true);
$table->timestamps();
});
Schema::create('plugins', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('version')->default('1.0.0');
$table->boolean('enabled')->default(false);
$table->string('path');
$table->json('config')->nullable();
$table->timestamps();
});
Schema::table('users', function (Blueprint $table) {
$table->string('username')->nullable()->unique()->after('name');
$table->string('password_legacy')->nullable()->after('password');
$table->string('url')->nullable()->after('password_legacy');
$table->unsignedInteger('login_count')->default(0)->after('url');
$table->string('login_ip', 45)->nullable()->after('login_count');
$table->timestamp('login_at')->nullable()->after('login_ip');
$table->string('reg_ip', 45)->nullable()->after('login_at');
$table->timestamp('last_post_at')->nullable()->after('reg_ip');
$table->string('email')->nullable()->change();
$table->string('password')->nullable()->change();
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn([
'username',
'password_legacy',
'url',
'login_count',
'login_ip',
'login_at',
'reg_ip',
'last_post_at',
]);
});
Schema::dropIfExists('plugins');
Schema::dropIfExists('stylevars');
Schema::dropIfExists('links');
Schema::dropIfExists('attachments');
Schema::dropIfExists('article_tag');
Schema::dropIfExists('tags');
Schema::dropIfExists('comments');
Schema::dropIfExists('articles');
Schema::dropIfExists('categories');
}
};
@@ -0,0 +1,49 @@
<?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::dropIfExists('trackbacks');
Schema::table('articles', function (Blueprint $table) {
if (Schema::hasColumn('articles', 'trackbacks_count')) {
$table->dropColumn('trackbacks_count');
}
if (Schema::hasColumn('articles', 'close_trackback')) {
$table->dropColumn('close_trackback');
}
if (! Schema::hasColumn('articles', 'slug')) {
$table->string('slug')->nullable()->unique()->after('keywords');
}
});
}
public function down(): void
{
Schema::table('articles', function (Blueprint $table) {
if (Schema::hasColumn('articles', 'slug')) {
$table->dropColumn('slug');
}
$table->unsignedInteger('trackbacks_count')->default(0);
$table->boolean('close_trackback')->default(false);
});
Schema::create('trackbacks', function (Blueprint $table) {
$table->id();
$table->foreignId('article_id')->constrained()->cascadeOnDelete();
$table->string('title');
$table->text('excerpt')->nullable();
$table->string('url');
$table->string('blog_name')->nullable();
$table->string('ip', 45)->nullable();
$table->boolean('visible')->default(false);
$table->timestamp('published_at')->nullable();
$table->timestamps();
});
}
};
@@ -0,0 +1,26 @@
<?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('articles', function (Blueprint $table) {
if (! Schema::hasColumn('articles', 'content_format')) {
$table->string('content_format', 16)->default('html')->after('content');
}
});
}
public function down(): void
{
Schema::table('articles', function (Blueprint $table) {
if (Schema::hasColumn('articles', 'content_format')) {
$table->dropColumn('content_format');
}
});
}
};
@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Phase-2 placeholders for auto/generated cover images.
* No generation pipeline in phase 1 queue/scripts will fill these later.
*/
return new class extends Migration
{
public function up(): void
{
Schema::table('articles', function (Blueprint $table) {
if (! Schema::hasColumn('articles', 'cover_disk')) {
$table->string('cover_disk')->nullable()->after('legacy_attachments');
}
if (! Schema::hasColumn('articles', 'cover_path')) {
$table->string('cover_path')->nullable()->after('cover_disk');
}
if (! Schema::hasColumn('articles', 'cover_source')) {
$table->string('cover_source', 32)->default('none')->after('cover_path');
}
if (! Schema::hasColumn('articles', 'cover_status')) {
$table->string('cover_status', 32)->default('none')->after('cover_source');
}
if (! Schema::hasColumn('articles', 'cover_generated_at')) {
$table->timestamp('cover_generated_at')->nullable()->after('cover_status');
}
});
}
public function down(): void
{
Schema::table('articles', function (Blueprint $table) {
foreach (['cover_disk', 'cover_path', 'cover_source', 'cover_status', 'cover_generated_at'] as $column) {
if (Schema::hasColumn('articles', $column)) {
$table->dropColumn($column);
}
}
});
}
};