init backend presensi

This commit is contained in:
mwpn
2026-03-05 14:37:36 +07:00
commit b4fda6b9c9
319 changed files with 27261 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateAttendanceSessionsTable extends Migration
{
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'student_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'schedule_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'null' => true,
],
'device_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'checkin_at' => [
'type' => 'DATETIME',
],
'latitude' => [
'type' => 'DECIMAL',
'constraint' => '10,8',
],
'longitude' => [
'type' => 'DECIMAL',
'constraint' => '11,8',
],
'confidence' => [
'type' => 'DECIMAL',
'constraint' => '5,2',
'null' => true,
],
'status' => [
'type' => 'ENUM',
'constraint' => ['PRESENT', 'LATE', 'OUTSIDE_ZONE', 'NO_SCHEDULE', 'INVALID_DEVICE'],
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addKey(['student_id', 'checkin_at']);
$this->forge->addKey('schedule_id');
$this->forge->addKey('device_id');
$this->forge->addForeignKey('student_id', 'students', 'id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('schedule_id', 'schedules', 'id', 'SET NULL', 'CASCADE');
$this->forge->addForeignKey('device_id', 'devices', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('attendance_sessions');
}
public function down()
{
$this->forge->dropTable('attendance_sessions');
}
}