Update Contact & UserLogin
This commit is contained in:
parent
9f83199ddf
commit
2ddd748c71
@ -22,10 +22,17 @@ class CreateContactTable extends Migration {
|
||||
'Specialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||
'SubSpecialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||
'Password' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
|
||||
|
||||
// Untuk Auth
|
||||
'LockedAt' => [ 'type' => 'DATETIME', 'null' => true ],
|
||||
'LockReason' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
||||
'Role' => [ 'type' => "ENUM('admin','staff','user')", 'default' => 'user', 'null' => false ],
|
||||
|
||||
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
||||
'EndDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
||||
]);
|
||||
$this->forge->addKey('ContactID', true);
|
||||
$this->forge->addUniqueKey('EmailAddress1');
|
||||
$this->forge->createTable('contact');
|
||||
|
||||
// ContactDetail
|
||||
|
||||
55
app/Database/Migrations/2025-12-01-100001_DeviceLogin.php
Normal file
55
app/Database/Migrations/2025-12-01-100001_DeviceLogin.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateDeviceLoginTable extends Migration {
|
||||
|
||||
public function up() {
|
||||
|
||||
// ===== userdevices =====
|
||||
$this->forge->addField([
|
||||
'UserDeviceId' => ['type' => 'CHAR', 'constraint' => 36],
|
||||
'ContactID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||
'DeviceFingerprint' => ['type' => 'CHAR', 'constraint' => 64],
|
||||
|
||||
'DeviceLabel' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
|
||||
'Browser' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||
'BrowserVersion' => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
|
||||
'Platform' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||
'Timezone' => ['type' => 'VARCHAR', 'constraint' => 50],
|
||||
'Language' => ['type' => 'VARCHAR', 'constraint' => 10],
|
||||
'IpAddress' => ['type' => 'VARCHAR', 'constraint' => 45],
|
||||
'FirstLoginAt' => ['type' => 'DATETIME'],
|
||||
'LastLoginAt' => ['type' => 'DATETIME'],
|
||||
'IsActive' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 1],
|
||||
]);
|
||||
|
||||
$this->forge->addKey('UserDeviceId', true);
|
||||
$this->forge->addKey(['ContactID', 'DeviceFingerprint'], false, true);
|
||||
$this->forge->createTable('userdevices', true);
|
||||
|
||||
// ===== loginattempts =====
|
||||
$this->forge->addField([
|
||||
'LoginAttemptId' => ['type' => 'BIGINT', 'unsigned' => true, 'auto_increment' => true],
|
||||
'ContactID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
||||
'DeviceId' => ['type' => 'CHAR', 'constraint' => 36, 'null' => true],
|
||||
'IpAddress' => ['type' => 'VARCHAR', 'constraint' => 45],
|
||||
'AttemptAt' => ['type' => 'DATETIME'],
|
||||
'IsSuccess' => ['type' => 'TINYINT', 'constraint' => 1],
|
||||
'FailureReason' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
||||
]);
|
||||
|
||||
$this->forge->addKey('LoginAttemptId', true);
|
||||
$this->forge->addKey('ContactID');
|
||||
$this->forge->addKey(['IpAddress', 'AttemptAt']);
|
||||
$this->forge->addKey(['ContactID', 'AttemptAt']);
|
||||
|
||||
$this->forge->createTable('loginattempts', true);
|
||||
}
|
||||
|
||||
public function down() {
|
||||
$this->forge->dropTable('loginattempts', true);
|
||||
$this->forge->dropTable('userdevices', true);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user