Files
yogibook_aury_new/db/migrations/20260917065654_create_event_locations_table.php
T
2026-09-17 10:22:30 +02:00

43 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateEventLocationsTable extends AbstractMigration
{
public function change(): void
{
$table = $this->table('event_locations', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
]);
$table
->addColumn('id', 'biginteger', ['identity' => true, 'signed' => false])
->addColumn('name', 'string', ['limit' => 191, 'null' => false, 'comment' => 'etichetta sede, es. "Studio YogaSoul"'])
->addColumn('address', 'string', ['limit' => 255, 'null' => false])
->addColumn('lat', 'decimal', ['precision' => 10, 'scale' => 7, 'null' => true])
->addColumn('lng', 'decimal', ['precision' => 10, 'scale' => 7, 'null' => true])
->addColumn('is_default', 'char', ['limit' => 1, 'null' => false, 'default' => 'N', 'comment' => 'Y = preselezionata'])
->addColumn('created_at', 'timestamp', ['null' => true, 'default' => null])
->addColumn('updated_at', 'timestamp', ['null' => true, 'default' => null])
->addIndex(['is_default'], ['name' => 'event_locations_is_default_index'])
->create();
// Sede di default (MODIFICA con indirizzo e coordinate reali della scuola)
$this->table('event_locations')->insert([
'name' => 'Studio YogaSoul',
'address' => 'Indirizzo da compilare',
'lat' => null,
'lng' => null,
'is_default' => 'Y',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
])->saveData();
}
}