You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kwpayroll/app/Database/Migrations/2024-08-31-160825_ExtendUse...

53 lines
1.2 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Forge;
use CodeIgniter\Database\Migration;
class ExtendUserFields extends Migration
{
private array $tables;
public function __construct(?Forge $forge = null)
{
parent::__construct($forge);
/** @var \Config\Auth $authConfig */
$authConfig = config('Auth');
$this->tables = $authConfig->tables;
}
public function up()
{
$fields = [
'company_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'employee_id' => [
'type' => 'VARCHAR',
'constraint' => '20',
'null' => false
],
'display_name' => [
'type' => 'VARCHAR',
'constraint' => '150',
'null' => false
],
];
$this->forge->addColumn($this->tables['users'], $fields);
}
public function down()
{
$fields = [
'company_id',
'employee_id',
'display_name',
];
$this->forge->dropColumn($this->tables['users'], $fields);
}
}