<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;
use CodeIgniter\Database\Config;

class Default_Password extends Migration
{
    public function up()
    {
        // Load the database connection
    $db = \Config\Database::connect();

    // Update the 'usr_passwd' field in the 'tbl_user' table
    $sql = "UPDATE tbl_user SET usr_passwd = ?";
    $password = enpass('hampo'); // Replace 'enpass' with your password hashing function

    // echo $password;
    $db->query($sql, [$password]); // Use parameterized query
    // echo "<br>Updated passwords in 'tbl_user'.<br>";

    $sql = "UPDATE tbl_user SET usr_passwd = ? where usr_login='admin'";
    $password = enpass('Ankur#123'); // Replace 'enpass' with your password hashing function

    // echo $password;

    $db->query($sql, [$password]); // Use parameterized query
    // echo "<br>Updated passwords in 'tbl_user'.<br>";

    }

    public function down()
    {
        // Drop the 'testtable' if it exists
        // $this->forge->dropTable('testtable1');
    }
}
