clqms-be/app/Database/Migrations/2025-12-29-150000_EdgeRes.php

59 lines
2.5 KiB
PHP
Raw Normal View History

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateEdgeResTables extends Migration {
public function up() {
// Main edgeres table - staging for instrument results
$this->forge->addField([
'EdgeResID' => ['type' => 'INT', 'auto_increment' => true],
'SiteID' => ['type' => 'INT', 'null' => true],
'InstrumentID' => ['type' => 'varchar', 'constraint' => 100, 'null' => true],
'SampleID' => ['type' => 'varchar', 'constraint' => 30, 'null' => true],
'PatientID' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
'Payload' => ['type' => 'TEXT', 'null' => true],
'Status' => ['type' => 'varchar', 'constraint' => 20, 'default' => 'pending'],
'AutoProcess' => ['type' => 'TINYINT', 'default' => 0, 'null' => true],
'ProcessedAt' => ['type' => 'DATETIME', 'null' => true],
'ErrorMessage' => ['type' => 'TEXT', 'null' => true],
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true],
'ArchiveDate' => ['type' => 'DATETIME', 'null' => true],
'DelDate' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('EdgeResID');
$this->forge->createTable('edgeres');
// Edge status log - for instrument status tracking
$this->forge->addField([
'EdgeStatusID' => ['type' => 'INT', 'auto_increment' => true],
'InstrumentID' => ['type' => 'varchar', 'constraint' => 100, 'null' => true],
'Status' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
'LastActivity' => ['type' => 'DATETIME', 'null' => true],
'Timestamp' => ['type' => 'DATETIME', 'null' => true],
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('EdgeStatusID');
$this->forge->createTable('edgestatus');
// Edge order acknowledgment log
$this->forge->addField([
'EdgeAckID' => ['type' => 'INT', 'auto_increment' => true],
'OrderID' => ['type' => 'INT', 'null' => true],
'InstrumentID' => ['type' => 'varchar', 'constraint' => 100, 'null' => true],
'AckDate' => ['type' => 'DATETIME', 'null' => true],
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('EdgeAckID');
$this->forge->createTable('edgeack');
}
public function down() {
$this->forge->dropTable('edgeack', true);
$this->forge->dropTable('edgestatus', true);
$this->forge->dropTable('edgeres', true);
}
}