tinyqc/app/Database/Migrations/2026-01-18-000001-RenameDictToMasterTables.php
mahdahar 5cae572916 Refactor application structure, unify entry management, and overhaul UI with DaisyUI
- 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.
2026-01-19 06:37:37 +07:00

46 lines
1.3 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class RenameDictToMasterTables extends Migration {
public function up() {
$db = \Config\Database::connect();
$db->query('SET FOREIGN_KEY_CHECKS=0');
$tables = $db->listTables();
if (in_array('dict_depts', $tables)) {
$db->query('RENAME TABLE dict_depts TO master_depts');
}
if (in_array('dict_controls', $tables)) {
$db->query('RENAME TABLE dict_controls TO master_controls');
}
if (in_array('dict_tests', $tables)) {
$db->query('RENAME TABLE dict_tests TO master_tests');
}
$db->query('SET FOREIGN_KEY_CHECKS=1');
}
public function down() {
$db = \Config\Database::connect();
$db->query('SET FOREIGN_KEY_CHECKS=0');
$tables = $db->listTables();
if (in_array('master_depts', $tables)) {
$db->query('RENAME TABLE master_depts TO dict_depts');
}
if (in_array('master_controls', $tables)) {
$db->query('RENAME TABLE master_controls TO dict_controls');
}
if (in_array('master_tests', $tables)) {
$db->query('RENAME TABLE master_tests TO dict_tests');
}
$db->query('SET FOREIGN_KEY_CHECKS=1');
}
}