- Reorganized Architecture: Moved Master data management (Controls, Departments, Tests) to a dedicated Master namespace/directory for better modularity.
- Unified Data Entry: Consolidated daily and monthly QC entry views and logic into a single streamlined system.
- UI/UX Modernization:
- Integrated DaisyUI and Alpine.js for a responsive, themeable, and interactive experience.
- Replaced legacy layouts with a new DaisyUI-based template.
- Updated branding with new logo and favicon assets.
- Cleaned up deprecated JavaScript assets (app.js, charts.js, tables.js).
- Backend Enhancements:
- Added `ControlEntryModel` and `ResultCommentsController` for improved data handling and auditing.
- Updated routing to support the new controller structure and consolidated API endpoints.
- Documentation & Assets:
- Added [docs/PRD.md](cci:7://file:///c:/www/tinyqc/docs/PRD.md:0:0-0:0) and [docs/llms.txt](cci:7://file:///c:/www/tinyqc/docs/llms.txt:0:0-0:0) for project context and requirements.
- Included database schema scripts and backups in the `backup/` directory.
- Cleanup: Removed legacy TUI progress files and unused commands.
108 lines
5.9 KiB
PHP
108 lines
5.9 KiB
PHP
<?php
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class QualityControlSystem extends Migration {
|
|
|
|
public function up() {
|
|
$this->forge->addField([
|
|
'dept_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
|
'name' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('dept_id', true);
|
|
$this->forge->createTable('dict_depts');
|
|
|
|
$this->forge->addField([
|
|
'control_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
|
'dept_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
|
'name' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'lot' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'producer' => ['type' => 'TEXT', 'null' => true],
|
|
'exp_date' => ['type' => 'DATE', 'null' => true],
|
|
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('control_id', true);
|
|
$this->forge->addForeignKey('dept_id', 'dict_depts', 'dept_id', 'SET NULL', 'CASCADE');
|
|
$this->forge->createTable('dict_controls');
|
|
|
|
$this->forge->addField([
|
|
'test_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
|
'dept_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
|
'name' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'unit' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'method' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'cva' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'ba' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'tea' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('test_id', true);
|
|
$this->forge->addForeignKey('dept_id', 'dict_depts', 'dept_id', 'SET NULL', 'CASCADE');
|
|
$this->forge->createTable('dict_tests');
|
|
|
|
$this->forge->addField([
|
|
'control_test_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
|
'control_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
|
'test_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
|
'mean' => ['type' => 'FLOAT', 'null' => true],
|
|
'sd' => ['type' => 'FLOAT', 'null' => true],
|
|
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('control_test_id', true);
|
|
$this->forge->addForeignKey('control_id', 'dict_controls', 'control_id', 'SET NULL', 'CASCADE');
|
|
$this->forge->addForeignKey('test_id', 'dict_tests', 'test_id', 'SET NULL', 'CASCADE');
|
|
$this->forge->createTable('control_tests');
|
|
|
|
$this->forge->addField([
|
|
'result_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
|
'control_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
|
'test_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
|
'res_date' => ['type' => 'DATETIME', 'null' => true],
|
|
'res_value' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'res_comment' => ['type' => 'TEXT', 'null' => true],
|
|
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('result_id', true);
|
|
$this->forge->addForeignKey('control_id', 'dict_controls', 'control_id', 'SET NULL', 'CASCADE');
|
|
$this->forge->addForeignKey('test_id', 'dict_tests', 'test_id', 'SET NULL', 'CASCADE');
|
|
$this->forge->createTable('results');
|
|
|
|
$this->forge->addField([
|
|
'result_comment_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
|
'control_id' => ['type' => 'INT', 'unsigned' => true],
|
|
'test_id' => ['type' => 'INT', 'unsigned' => true],
|
|
'comment_month' => ['type' => 'VARCHAR', 'constraint' => 7],
|
|
'com_text' => ['type' => 'TEXT', 'null' => true],
|
|
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('result_comment_id', true);
|
|
$this->forge->addUniqueKey(['control_id', 'test_id', 'comment_month']);
|
|
$this->forge->addForeignKey('control_id', 'dict_controls', 'control_id', 'CASCADE', 'CASCADE');
|
|
$this->forge->addForeignKey('test_id', 'dict_tests', 'test_id', 'CASCADE', 'CASCADE');
|
|
$this->forge->createTable('result_comments');
|
|
}
|
|
|
|
public function down() {
|
|
$this->forge->dropTable('result_comments', true);
|
|
$this->forge->dropTable('results', true);
|
|
$this->forge->dropTable('control_tests', true);
|
|
$this->forge->dropTable('dict_tests', true);
|
|
$this->forge->dropTable('dict_controls', true);
|
|
$this->forge->dropTable('dict_depts', true);
|
|
}
|
|
}
|