61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateMescoleFilesTable extends AbstractMigration
|
|
{
|
|
public function change(): void
|
|
{
|
|
$table = $this->table('mescole_files', [
|
|
'id' => 'id',
|
|
'signed' => true,
|
|
'engine' => 'InnoDB',
|
|
'charset' => 'utf8mb4',
|
|
'collation' => 'utf8mb4_general_ci',
|
|
]);
|
|
|
|
$table
|
|
->addColumn('idmescola', 'integer', [
|
|
'signed' => true,
|
|
'null' => false,
|
|
])
|
|
->addColumn('categoria', 'string', [
|
|
'limit' => 100,
|
|
'null' => false,
|
|
'comment' => 'slug categoria: schede_tecniche, certificati_analisi, ...',
|
|
])
|
|
->addColumn('titolo', 'string', [
|
|
'limit' => 255,
|
|
'null' => false,
|
|
])
|
|
->addColumn('filename', 'string', [
|
|
'limit' => 255,
|
|
'null' => false,
|
|
'comment' => 'nome fisico del file salvato su disco (random, non l\'originale)',
|
|
])
|
|
->addColumn('original_filename', 'string', [
|
|
'limit' => 255,
|
|
'null' => false,
|
|
])
|
|
->addColumn('mime_type', 'string', [
|
|
'limit' => 150,
|
|
'null' => true,
|
|
])
|
|
->addColumn('filesize', 'integer', [
|
|
'null' => true,
|
|
])
|
|
->addColumn('uploaded_at', 'datetime', [
|
|
'default' => 'CURRENT_TIMESTAMP',
|
|
])
|
|
->addIndex(['idmescola'])
|
|
->addIndex(['categoria'])
|
|
->addForeignKey('idmescola', 'mescole', 'id', [
|
|
'delete' => 'CASCADE',
|
|
'update' => 'CASCADE',
|
|
])
|
|
->create();
|
|
}
|
|
}
|