<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/**
 * The initial Nextcloud admin password no longer travels to the customer by
 * mail. It moves here — encrypted, same as nc_admin_ref — and stays only
 * until the customer confirms they have noted it, at which point it is
 * deleted and credentials_acknowledged_at is stamped.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('instances', function (Blueprint $table) {
            $table->text('admin_password')->nullable()->after('nc_admin_ref');
            $table->timestamp('credentials_acknowledged_at')->nullable()->after('admin_password');
        });
    }

    public function down(): void
    {
        Schema::table('instances', function (Blueprint $table) {
            $table->dropColumn(['admin_password', 'credentials_acknowledged_at']);
        });
    }
};
