fix enrollment logic, add financial aid, fix class distribution
Tests / PHPUnit (push) Failing after 1m6s
Tests / PHPUnit (push) Failing after 1m6s
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class EnrollmentCarryOverAndExceptionUniqueness extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
if ($this->db->tableExists('school_years') && $this->db->fieldExists('carry_over_balance_behavior', 'school_years')) {
|
||||
$this->db->table('school_years')
|
||||
->groupStart()
|
||||
->where('carry_over_balance_behavior', 'information_only')
|
||||
->orWhere('carry_over_balance_behavior', null)
|
||||
->orWhere('carry_over_balance_behavior', '')
|
||||
->groupEnd()
|
||||
->update(['carry_over_balance_behavior' => 'submission_blocked_until_payment']);
|
||||
}
|
||||
|
||||
if (! $this->db->tableExists('enrollment_exceptions')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$indexes = $this->db->query('SHOW INDEX FROM enrollment_exceptions')->getResultArray();
|
||||
$names = array_map(static fn (array $row): string => (string) ($row['Key_name'] ?? ''), $indexes);
|
||||
if (in_array('uniq_enrollment_exceptions_scope_status', $names, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->db->query(
|
||||
'ALTER TABLE enrollment_exceptions ADD UNIQUE INDEX uniq_enrollment_exceptions_scope_status (parent_id, student_id, school_year, status)'
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', 'Unable to add unique enrollment exception index: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
if ($this->db->tableExists('enrollment_exceptions')) {
|
||||
try {
|
||||
$this->db->query('ALTER TABLE enrollment_exceptions DROP INDEX uniq_enrollment_exceptions_scope_status');
|
||||
} catch (\Throwable $e) {
|
||||
// Index may not exist.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user