fix test issues
API CI/CD / Validate (composer + pint) (push) Successful in 3m5s
API CI/CD / Test (PHPUnit) (push) Failing after 7m12s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped

This commit is contained in:
root
2026-07-06 02:39:13 -04:00
parent 90f9857b06
commit 304fa6bfd0
14 changed files with 1018 additions and 17 deletions
@@ -0,0 +1,114 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
// email_templates: missing created_at
$this->addColumns('email_templates', [
'created_at' => fn (Blueprint $table) => $table->timestamp('created_at')->nullable(),
]);
// class_prep_adjustments: missing updated_at
$this->addColumns('class_prep_adjustments', [
'updated_at' => fn (Blueprint $table) => $table->timestamp('updated_at')->nullable(),
]);
// late_slip_logs: printed_at should be nullable
if (Schema::hasTable('late_slip_logs') && Schema::hasColumn('late_slip_logs', 'printed_at')) {
Schema::table('late_slip_logs', function (Blueprint $table) {
$table->timestamp('printed_at')->nullable()->default(null)->change();
});
}
// payments: number_of_installments needs default
if (Schema::hasTable('payments') && Schema::hasColumn('payments', 'number_of_installments')) {
Schema::table('payments', function (Blueprint $table) {
$table->unsignedInteger('number_of_installments')->default(1)->change();
});
}
// ip_attempts: last_attempt_at needs default
if (Schema::hasTable('ip_attempts') && Schema::hasColumn('ip_attempts', 'last_attempt_at')) {
Schema::table('ip_attempts', function (Blueprint $table) {
$table->timestamp('last_attempt_at')->useCurrent()->change();
});
}
}
public function down(): void
{
$this->dropColumns('email_templates', ['created_at']);
$this->dropColumns('class_prep_adjustments', ['updated_at']);
if (Schema::hasTable('late_slip_logs') && Schema::hasColumn('late_slip_logs', 'printed_at')) {
Schema::table('late_slip_logs', function (Blueprint $table) {
$table->timestamp('printed_at')->nullable(false)->change();
});
}
if (Schema::hasTable('payments') && Schema::hasColumn('payments', 'number_of_installments')) {
Schema::table('payments', function (Blueprint $table) {
$table->unsignedInteger('number_of_installments')->default(null)->change();
});
}
if (Schema::hasTable('ip_attempts') && Schema::hasColumn('ip_attempts', 'last_attempt_at')) {
Schema::table('ip_attempts', function (Blueprint $table) {
$table->timestamp('last_attempt_at')->useCurrent(false)->change();
});
}
}
/**
* @param array<string, callable(Blueprint): void> $columns
*/
private function addColumns(string $table, array $columns): void
{
if (! Schema::hasTable($table)) {
return;
}
$missing = array_filter(
array_keys($columns),
static fn (string $column): bool => ! Schema::hasColumn($table, $column)
);
if ($missing === []) {
return;
}
Schema::table($table, function (Blueprint $blueprint) use ($columns, $missing): void {
foreach ($missing as $column) {
$columns[$column]($blueprint);
}
});
}
/**
* @param list<string> $columns
*/
private function dropColumns(string $table, array $columns): void
{
if (! Schema::hasTable($table)) {
return;
}
$existing = array_filter(
$columns,
static fn (string $column): bool => Schema::hasColumn($table, $column)
);
if ($existing === []) {
return;
}
Schema::table($table, function (Blueprint $blueprint) use ($existing): void {
$blueprint->dropColumn($existing);
});
}
};