@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddRefundReconciliationFields extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
if (!$this->db->tableExists('refunds')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$columns = [];
|
||||
if (!$this->db->fieldExists('reconciliation_status', 'refunds')) {
|
||||
$columns['reconciliation_status'] = [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 30,
|
||||
'null' => true,
|
||||
'after' => 'approved_amount_cents',
|
||||
];
|
||||
}
|
||||
if (!$this->db->fieldExists('reconciliation_reason', 'refunds')) {
|
||||
$columns['reconciliation_reason'] = [
|
||||
'type' => 'TEXT',
|
||||
'null' => true,
|
||||
'after' => 'reconciliation_status',
|
||||
];
|
||||
}
|
||||
if (!$this->db->fieldExists('reconciliation_required_at', 'refunds')) {
|
||||
$columns['reconciliation_required_at'] = [
|
||||
'type' => 'DATETIME',
|
||||
'null' => true,
|
||||
'after' => 'reconciliation_reason',
|
||||
];
|
||||
}
|
||||
|
||||
if ($columns !== []) {
|
||||
$this->forge->addColumn('refunds', $columns);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
if (!$this->db->tableExists('refunds')) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (['reconciliation_status', 'reconciliation_reason', 'reconciliation_required_at'] as $column) {
|
||||
if ($this->db->fieldExists($column, 'refunds')) {
|
||||
$this->forge->dropColumn('refunds', $column);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user