86 lines
4.0 KiB
PHP
86 lines
4.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class ExtendSchoolsProfile extends AbstractMigration
|
|
{
|
|
public function up(): void
|
|
{
|
|
// 1) Anagrafica e pagina pubblica della scuola
|
|
$this->table('schools')
|
|
->addColumn('legal_name', 'string', ['limit' => 191, 'null' => true, 'comment' => 'ragione sociale'])
|
|
->addColumn('tax_code', 'string', ['limit' => 20, 'null' => true, 'comment' => 'codice fiscale'])
|
|
->addColumn('sdi_code', 'string', ['limit' => 7, 'null' => true, 'comment' => 'codice destinatario SDI'])
|
|
->addColumn('pec', 'string', ['limit' => 191, 'null' => true])
|
|
->addColumn('whatsapp', 'string', ['limit' => 30, 'null' => true])
|
|
->addColumn('province', 'string', ['limit' => 50, 'null' => true])
|
|
->addColumn('lat', 'decimal', ['precision' => 10, 'scale' => 7, 'null' => true])
|
|
->addColumn('lng', 'decimal', ['precision' => 10, 'scale' => 7, 'null' => true])
|
|
->addColumn('short_description', 'string', ['limit' => 255, 'null' => true, 'comment' => 'slogan / sottotitolo'])
|
|
->addColumn('description', 'text', ['null' => true, 'comment' => 'descrizione scuola'])
|
|
->addColumn('courses_description', 'text', ['null' => true, 'comment' => 'descrizione corsi'])
|
|
->addColumn('opening_hours', 'text', ['null' => true, 'comment' => 'orari (testo libero)'])
|
|
->addColumn('website', 'string', ['limit' => 191, 'null' => true])
|
|
->addColumn('instagram', 'string', ['limit' => 191, 'null' => true])
|
|
->addColumn('facebook', 'string', ['limit' => 191, 'null' => true])
|
|
->addColumn('youtube', 'string', ['limit' => 191, 'null' => true])
|
|
->update();
|
|
|
|
// 2) Galleria immagini (max 10 per scuola, limite applicato dall'app)
|
|
$this->table('school_images', [
|
|
'id' => false,
|
|
'primary_key' => ['idimage'],
|
|
'engine' => 'InnoDB',
|
|
'collation' => 'utf8mb4_unicode_ci',
|
|
])
|
|
->addColumn('idimage', 'integer', ['signed' => false, 'identity' => true])
|
|
->addColumn('idschool', 'integer', ['signed' => false])
|
|
->addColumn('filename', 'string', ['limit' => 191])
|
|
->addColumn('is_cover', 'char', ['limit' => 1, 'default' => 'N'])
|
|
->addColumn('sort_order', 'integer', ['default' => 0])
|
|
->addColumn('created_at', 'timestamp', ['null' => true, 'default' => 'CURRENT_TIMESTAMP'])
|
|
->addIndex(['idschool'], ['name' => 'school_images_idschool_index'])
|
|
->addForeignKey('idschool', 'schools', 'idschool', ['delete' => 'CASCADE', 'update' => 'NO_ACTION'])
|
|
->create();
|
|
|
|
// 3) Colori del tema (NULL = colori standard del template)
|
|
$this->table('option')
|
|
->addColumn('theme_primary', 'string', ['limit' => 7, 'null' => true])
|
|
->addColumn('theme_sidebar', 'string', ['limit' => 7, 'null' => true])
|
|
->addColumn('theme_topbar', 'string', ['limit' => 7, 'null' => true])
|
|
->update();
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
$this->table('option')
|
|
->removeColumn('theme_primary')
|
|
->removeColumn('theme_sidebar')
|
|
->removeColumn('theme_topbar')
|
|
->update();
|
|
|
|
$this->table('school_images')->drop()->save();
|
|
|
|
$this->table('schools')
|
|
->removeColumn('legal_name')
|
|
->removeColumn('tax_code')
|
|
->removeColumn('sdi_code')
|
|
->removeColumn('pec')
|
|
->removeColumn('whatsapp')
|
|
->removeColumn('province')
|
|
->removeColumn('lat')
|
|
->removeColumn('lng')
|
|
->removeColumn('short_description')
|
|
->removeColumn('description')
|
|
->removeColumn('courses_description')
|
|
->removeColumn('opening_hours')
|
|
->removeColumn('website')
|
|
->removeColumn('instagram')
|
|
->removeColumn('facebook')
|
|
->removeColumn('youtube')
|
|
->update();
|
|
}
|
|
}
|