<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        $settings = [
            ['key' => 'sms_oauth_username', 'value' => ''],
            ['key' => 'sms_oauth_password', 'value' => ''],
            ['key' => 'sms_channel_id', 'value' => ''],
        ];

        foreach ($settings as $setting) {
            DB::table('settings')->updateOrInsert(
                ['key' => $setting['key']],
                array_merge($setting, ['created_at' => now(), 'updated_at' => now()])
            );
        }
    }

    public function down(): void
    {
        DB::table('settings')->whereIn('key', [
            'sms_oauth_username',
            'sms_oauth_password',
            'sms_channel_id',
        ])->delete();
    }
};
