49 lines
2.5 KiB
PHP
49 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateEnrollmentExceptions extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
if ($this->db->tableExists('enrollment_exceptions')) {
|
|
return;
|
|
}
|
|
|
|
$this->forge->addField([
|
|
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
|
'parent_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
|
'student_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true],
|
|
'school_year' => ['type' => 'VARCHAR', 'constraint' => 20],
|
|
'source_school_year' => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
|
|
'status' => ['type' => 'VARCHAR', 'constraint' => 20, 'default' => 'active'],
|
|
'reason_code' => ['type' => 'VARCHAR', 'constraint' => 80],
|
|
'reason_note' => ['type' => 'TEXT'],
|
|
'bypassed_rule_codes_json' => ['type' => 'TEXT', 'null' => true],
|
|
'created_by' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true],
|
|
'approved_by' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true],
|
|
'starts_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'expires_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'used_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'enrollment_id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true],
|
|
'revoked_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'revoked_by' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'null' => true],
|
|
'revocation_reason' => ['type' => 'TEXT', 'null' => true],
|
|
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('id', true);
|
|
$this->forge->addKey(['parent_id', 'student_id', 'school_year', 'status'], false, false, 'idx_enrollment_exceptions_scope_status');
|
|
$this->forge->addKey(['student_id', 'school_year'], false, false, 'idx_enrollment_exceptions_student_year');
|
|
$this->forge->addKey(['status', 'expires_at'], false, false, 'idx_enrollment_exceptions_status_expiry');
|
|
$this->forge->createTable('enrollment_exceptions', true);
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable('enrollment_exceptions', true);
|
|
}
|
|
}
|