Files
alrahma_sunday_school/app/Database/Migrations/2026-09-03-000120_AddPostedAtToJobPositions.php
root c70f6bdc6e
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 54s
Tests / PHPUnit (push) Successful in 1m22s
fix positions
2026-09-03 03:21:37 -04:00

39 lines
1.0 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddPostedAtToJobPositions extends Migration
{
public function up()
{
if (!$this->db->tableExists('job_positions')) {
return;
}
if (!$this->db->fieldExists('posted_at', 'job_positions')) {
$this->forge->addColumn('job_positions', [
'posted_at' => [
'type' => 'DATETIME',
'null' => true,
'after' => 'posted_by',
],
]);
}
$this->db->table('job_positions')
->whereIn('status', ['open', 'closed', 'filled'])
->where('posted_at', null)
->set('posted_at', 'COALESCE(created_at, updated_at)', false)
->update();
}
public function down()
{
if ($this->db->tableExists('job_positions') && $this->db->fieldExists('posted_at', 'job_positions')) {
$this->forge->dropColumn('job_positions', 'posted_at');
}
}
}