44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
/**
|
|
* Ex public/userarea/sql/lims_value_binding.sql (feature/xls-mapping)
|
|
*/
|
|
final class CreateLimsValueBinding extends AbstractMigration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if ($this->hasTable('lims_value_binding')) {
|
|
return;
|
|
}
|
|
|
|
$this->execute("
|
|
CREATE TABLE `lims_value_binding` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`template_id` int(11) NOT NULL,
|
|
`mapping_id` int(11) NOT NULL,
|
|
`field_id` int(11) NOT NULL,
|
|
`source_value` varchar(500) NOT NULL,
|
|
`source_key` varchar(500) NOT NULL,
|
|
`lims_value_id` int(11) NOT NULL,
|
|
`lims_value` varchar(500) DEFAULT NULL,
|
|
`created_by` int(11) DEFAULT NULL,
|
|
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uq_mapping_source` (`mapping_id`, `source_key`),
|
|
KEY `idx_template` (`template_id`),
|
|
KEY `idx_field_source` (`field_id`, `source_key`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
|
|
");
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
$this->execute("DROP TABLE IF EXISTS `lims_value_binding`");
|
|
}
|
|
}
|