27 lines
653 B
PHP
27 lines
653 B
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class BackfillPostedAtForClosedFilledJobPositions extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
if (!$this->db->tableExists('job_positions') || !$this->db->fieldExists('posted_at', 'job_positions')) {
|
|
return;
|
|
}
|
|
|
|
$this->db->table('job_positions')
|
|
->whereIn('status', ['closed', 'filled'])
|
|
->where('posted_at', null)
|
|
->set('posted_at', 'COALESCE(created_at, updated_at)', false)
|
|
->update();
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
// Data-only fallback for legacy rows.
|
|
}
|
|
}
|