added assorbimento corso
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateTrainingTopicCoverage extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table('training_topic_coverage', [
|
||||
'id' => 'id',
|
||||
'signed' => false,
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
|
||||
$table
|
||||
->addColumn('topic_id', 'integer', [
|
||||
'signed' => false,
|
||||
'null' => false,
|
||||
'comment' => 'Corso madre (es. RSPP)',
|
||||
])
|
||||
->addColumn('covered_topic_id', 'integer', [
|
||||
'signed' => false,
|
||||
'null' => false,
|
||||
'comment' => 'Corso assorbito (es. Antincendio)',
|
||||
])
|
||||
->addColumn('inherit_expiry', 'enum', [
|
||||
'values' => ['own', 'source', 'none'],
|
||||
'default' => 'own',
|
||||
'null' => false,
|
||||
'comment' => 'own = ricalcola con frequenza propria del corso coperto',
|
||||
])
|
||||
->addColumn('notes', 'string', [
|
||||
'limit' => 255,
|
||||
'null' => true,
|
||||
])
|
||||
->addColumn('created_at', 'timestamp', [
|
||||
'default' => 'CURRENT_TIMESTAMP',
|
||||
'null' => true,
|
||||
])
|
||||
->addIndex(['topic_id', 'covered_topic_id'], [
|
||||
'unique' => true,
|
||||
'name' => 'uq_topic_coverage',
|
||||
])
|
||||
->addIndex(['covered_topic_id'], ['name' => 'idx_covered_topic'])
|
||||
->addForeignKey('topic_id', 'training_topics', 'id', [
|
||||
'delete' => 'CASCADE',
|
||||
'update' => 'CASCADE',
|
||||
'constraint' => 'fk_cov_topic',
|
||||
])
|
||||
->addForeignKey('covered_topic_id', 'training_topics', 'id', [
|
||||
'delete' => 'CASCADE',
|
||||
'update' => 'CASCADE',
|
||||
'constraint' => 'fk_cov_covered',
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user