Files
yogibook_aury_new/db/migrations/20261003120418_create_schools_table.php
T
2026-10-03 14:11:56 +02:00

53 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateSchoolsTable extends AbstractMigration
{
public function up(): void
{
$this->table('schools', [
'id' => false,
'primary_key' => ['idschool'],
'engine' => 'InnoDB',
'collation' => 'utf8mb4_unicode_ci',
])
->addColumn('idschool', 'integer', ['signed' => false, 'identity' => true])
->addColumn('name', 'string', ['limit' => 191])
->addColumn('slug', 'string', ['limit' => 100, 'comment' => 'usato per URL/sottodominio/widget'])
->addColumn('email', 'string', ['limit' => 191, 'null' => true])
->addColumn('phone', 'string', ['limit' => 40, 'null' => true])
->addColumn('address', 'string', ['limit' => 255, 'null' => true])
->addColumn('city', 'string', ['limit' => 100, 'null' => true])
->addColumn('postcode', 'string', ['limit' => 20, 'null' => true])
->addColumn('country', 'string', ['limit' => 2, 'default' => 'IT'])
->addColumn('vat_number', 'string', ['limit' => 30, 'null' => true])
->addColumn('logo', 'string', ['limit' => 191, 'null' => true])
->addColumn('timezone', 'string', ['limit' => 50, 'default' => 'Europe/Rome'])
->addColumn('locale', 'string', ['limit' => 5, 'default' => 'it'])
->addColumn('currency', 'string', ['limit' => 3, 'default' => 'EUR'])
->addColumn('status', 'string', ['limit' => 20, 'default' => 'active', 'comment' => 'active|suspended|trial'])
->addColumn('created_at', 'timestamp', ['null' => true, 'default' => 'CURRENT_TIMESTAMP'])
->addColumn('updated_at', 'timestamp', ['null' => true, 'default' => null, 'update' => 'CURRENT_TIMESTAMP'])
->addIndex(['slug'], ['unique' => true, 'name' => 'schools_slug_unique'])
->addIndex(['status'], ['name' => 'schools_status_index'])
->create();
// Seregno = scuola 1 (dati da completare poi dal pannello)
$this->table('schools')->insert([
'idschool' => 1,
'name' => 'Scuola Yoga Seregno',
'slug' => 'seregno',
'city' => 'Seregno',
'country' => 'IT',
])->saveData();
}
public function down(): void
{
$this->table('schools')->drop()->save();
}
}