pdf test routine
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddPdfSupportToTemplates extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
// 1) PDF di esempio + metadati pagine sul template
|
||||
$templates = $this->table('excel_templates');
|
||||
|
||||
if (!$templates->hasColumn('sample_pdf')) {
|
||||
$templates->addColumn('sample_pdf', 'string', [
|
||||
'limit' => 255,
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'after' => 'sample_xlsx',
|
||||
'comment' => 'Filename of the sample PDF used to draw regions',
|
||||
]);
|
||||
}
|
||||
|
||||
if (!$templates->hasColumn('pdf_page_meta')) {
|
||||
$templates->addColumn('pdf_page_meta', 'text', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'comment' => 'JSON: pages count and rendered dimensions per page',
|
||||
]);
|
||||
}
|
||||
|
||||
$templates->update();
|
||||
|
||||
// 2) Riquadri (etichetta + dato) per ogni campo mappato
|
||||
$mapping = $this->table('template_mapping');
|
||||
|
||||
if (!$mapping->hasColumn('pdf_regions')) {
|
||||
$mapping->addColumn('pdf_regions', 'text', [
|
||||
'null' => true,
|
||||
'default' => null,
|
||||
'after' => 'json_node',
|
||||
'comment' => 'JSON: {page, label:{x,y,w,h}, value:{x,y,w,h}}',
|
||||
]);
|
||||
}
|
||||
|
||||
$mapping->update();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddPdfToSourceTypeEnum extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->execute(
|
||||
"ALTER TABLE `excel_templates`
|
||||
MODIFY `source_type` ENUM('XLS','API','PDF') NOT NULL DEFAULT 'XLS'"
|
||||
);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->execute(
|
||||
"ALTER TABLE `excel_templates`
|
||||
MODIFY `source_type` ENUM('XLS','API') NOT NULL DEFAULT 'XLS'"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user