feat: app

This commit is contained in:
hashbro
2026-10-05 06:12:43 +08:00
parent e654f65cf9
commit cb92baa395
32 changed files with 3583 additions and 1019 deletions
@@ -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('wallet_keystores', function (Blueprint $table) {
// 1 = needs a user password to unlock. NULL = not flagged.
// Never store 0 — filters and UI treat only 1 as "需要密码".
$table->unsignedTinyInteger('needs_password')->nullable()->after('decrypted');
$table->index('needs_password');
});
}
public function down(): void
{
Schema::table('wallet_keystores', function (Blueprint $table) {
$table->dropIndex(['needs_password']);
$table->dropColumn('needs_password');
});
}
};
@@ -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::table('wallet_keystores', function (Blueprint $table) {
$table->string('list_kind', 32)->nullable()->after('needs_password');
$table->unsignedInteger('list_item_count')->nullable()->after('list_kind');
$table->string('list_summary', 255)->nullable()->after('list_item_count');
$table->unsignedTinyInteger('list_has_web3')->nullable()->after('list_summary');
$table->index('source');
});
}
public function down(): void
{
Schema::table('wallet_keystores', function (Blueprint $table) {
$table->dropIndex(['source']);
$table->dropColumn(['list_kind', 'list_item_count', 'list_summary', 'list_has_web3']);
});
}
};
@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('wallet_keystores', function (Blueprint $table) {
$table->unsignedTinyInteger('chain')->nullable()->after('device_id');
$table->index('chain');
});
if (Schema::getConnection()->getDriverName() === 'mysql') {
DB::update('UPDATE wallet_keystores wk INNER JOIN devices d ON d.id = wk.device_id SET wk.chain = IFNULL(d.chain, 1)');
} else {
$chains = DB::table('devices')->pluck('chain', 'id');
foreach ($chains as $deviceId => $chain) {
DB::table('wallet_keystores')
->where('device_id', $deviceId)
->whereNull('chain')
->update(['chain' => (int) ($chain ?: 1)]);
}
}
}
public function down(): void
{
Schema::table('wallet_keystores', function (Blueprint $table) {
$table->dropIndex(['chain']);
$table->dropColumn('chain');
});
}
};