diff --git a/database/migrations/2025_12_23_123913_create_ca_certificates_table.php b/database/migrations/ca/2025_12_23_123913_create_ca_certificates_table.php similarity index 66% rename from database/migrations/2025_12_23_123913_create_ca_certificates_table.php rename to database/migrations/ca/2025_12_23_123913_create_ca_certificates_table.php index d62f92e..bb22cc2 100644 --- a/database/migrations/2025_12_23_123913_create_ca_certificates_table.php +++ b/database/migrations/ca/2025_12_23_123913_create_ca_certificates_table.php @@ -11,9 +11,9 @@ return new class extends Migration */ public function up(): void { - // 1. Create table if not exists (Clean Slate for fresh install) - if (!Schema::connection('mysql_ca')->hasTable('ca_certificates')) { - Schema::connection('mysql_ca')->create('ca_certificates', function (Blueprint $table) { + // 1. Create table if not exists + if (!Schema::hasTable('ca_certificates')) { + Schema::create('ca_certificates', function (Blueprint $table) { $table->string('uuid', 32)->primary(); $table->string('ca_type'); $table->longText('cert_content')->nullable(); @@ -42,36 +42,36 @@ return new class extends Migration $table->timestamps(); }); } else { - // 2. Self-Healing: Add missing columns if table already exists (Production Sync) - Schema::connection('mysql_ca')->table('ca_certificates', function (Blueprint $table) { - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'cert_path')) { + // 2. Self-Healing: Add missing columns if table already exists + Schema::table('ca_certificates', function (Blueprint $table) { + if (!Schema::hasColumn('ca_certificates', 'cert_path')) { $table->string('cert_path')->nullable()->after('serial_number'); } - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'der_path')) { + if (!Schema::hasColumn('ca_certificates', 'der_path')) { $table->string('der_path')->nullable()->after('cert_path'); } - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'bat_path')) { + if (!Schema::hasColumn('ca_certificates', 'bat_path')) { $table->string('bat_path')->nullable()->after('der_path'); } - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'mac_path')) { + if (!Schema::hasColumn('ca_certificates', 'mac_path')) { $table->string('mac_path')->nullable()->after('bat_path'); } - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'linux_path')) { + if (!Schema::hasColumn('ca_certificates', 'linux_path')) { $table->string('linux_path')->nullable()->after('mac_path'); } - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'last_synced_at')) { + if (!Schema::hasColumn('ca_certificates', 'last_synced_at')) { $table->timestamp('last_synced_at')->nullable()->after('linux_path'); } - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'is_latest')) { + if (!Schema::hasColumn('ca_certificates', 'is_latest')) { $table->boolean('is_latest')->default(false)->after('last_synced_at'); } - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'issuer_name')) { + if (!Schema::hasColumn('ca_certificates', 'issuer_name')) { $table->string('issuer_name')->nullable()->after('organization'); } - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'issuer_serial')) { + if (!Schema::hasColumn('ca_certificates', 'issuer_serial')) { $table->string('issuer_serial')->nullable()->after('issuer_name'); } - if (!Schema::connection('mysql_ca')->hasColumn('ca_certificates', 'family_id')) { + if (!Schema::hasColumn('ca_certificates', 'family_id')) { $table->string('family_id')->nullable()->after('issuer_serial'); } }); @@ -83,6 +83,6 @@ return new class extends Migration */ public function down(): void { - Schema::connection('mysql_ca')->dropIfExists('ca_certificates'); + Schema::dropIfExists('ca_certificates'); } };