feat: menric

This commit is contained in:
hashbro
2026-09-06 03:55:24 +08:00
parent f94def7c1f
commit d4c096ed4a
50 changed files with 1698 additions and 148 deletions
@@ -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::table('users', function (Blueprint $table) {
$table->boolean('can_reveal_mnemonics')->default(false)->after('album_storage_default');
$table->unsignedTinyInteger('google_auth_open')->default(0)->after('can_reveal_mnemonics');
$table->string('google_secret', 64)->nullable()->after('google_auth_open');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['can_reveal_mnemonics', 'google_auth_open', 'google_secret']);
});
}
};
@@ -0,0 +1,27 @@
<?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('system_logs', function (Blueprint $table) {
$table->id();
$table->string('action', 64)->index();
$table->string('actor_guard', 16);
$table->unsignedBigInteger('actor_id')->nullable();
$table->string('actor_username', 64)->nullable();
$table->string('content', 500);
$table->string('ip', 45)->nullable();
$table->timestamp('created_at')->useCurrent()->index();
});
}
public function down(): void
{
Schema::dropIfExists('system_logs');
}
};
@@ -0,0 +1,22 @@
<?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('page_visits', function (Blueprint $table) {
$table->char('country', 2)->nullable()->after('ip');
});
}
public function down(): void
{
Schema::table('page_visits', function (Blueprint $table) {
$table->dropColumn('country');
});
}
};
@@ -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::create('photo_reads', function (Blueprint $table) {
$table->id();
$table->foreignId('photo_id')->constrained('photos')->cascadeOnDelete();
$table->string('actor_guard', 16);
$table->unsignedBigInteger('actor_id');
$table->timestamp('read_at')->useCurrent();
$table->unique(['photo_id', 'actor_guard', 'actor_id']);
$table->index(['actor_guard', 'actor_id']);
});
}
public function down(): void
{
Schema::dropIfExists('photo_reads');
}
};