43 lines
1.8 KiB
PHP
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();
|
|
}
|
|
}
|