events yogibook
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
final class CreateEventsTable extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table('events', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
|
||||
$table
|
||||
->addColumn('id', 'biginteger', ['identity' => true, 'signed' => false])
|
||||
->addColumn('user_id', 'integer', ['signed' => false, 'null' => true, 'comment' => 'insegnante/creatore -> auth_users.id'])
|
||||
->addColumn('title', 'string', ['limit' => 191, 'null' => false])
|
||||
->addColumn('slug', 'string', ['limit' => 191, 'null' => false, 'comment' => 'URL pubblico / widget'])
|
||||
->addColumn('description', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'comment' => 'HTML editor'])
|
||||
->addColumn('organizer_name', 'string', ['limit' => 191, 'null' => true, 'comment' => 'nome libero; se null usa il creatore'])
|
||||
->addColumn('starts_at', 'datetime', ['null' => false])
|
||||
->addColumn('ends_at', 'datetime', ['null' => true])
|
||||
->addColumn('address', 'string', ['limit' => 255, 'null' => true, 'comment' => 'testo per Google Maps'])
|
||||
->addColumn('lat', 'decimal', ['precision' => 10, 'scale' => 7, 'null' => true])
|
||||
->addColumn('lng', 'decimal', ['precision' => 10, 'scale' => 7, 'null' => true])
|
||||
->addColumn('cost', 'decimal', ['precision' => 8, 'scale' => 2, 'null' => false, 'default' => 0])
|
||||
->addColumn('currency', 'string', ['limit' => 3, 'null' => false, 'default' => 'EUR'])
|
||||
->addColumn('max_seats', 'integer', ['signed' => false, 'null' => false, 'default' => 0])
|
||||
->addColumn('max_per_booking', 'integer', ['signed' => false, 'null' => false, 'default' => 1])
|
||||
->addColumn('color', 'string', ['limit' => 7, 'null' => false, 'default' => '#4CAF50', 'comment' => 'hex card'])
|
||||
->addColumn('cover_image', 'string', ['limit' => 191, 'null' => true, 'comment' => 'gallery in futuro'])
|
||||
->addColumn('status', 'string', ['limit' => 20, 'null' => false, 'default' => 'draft', 'comment' => 'draft|published|cancelled'])
|
||||
->addColumn('created_at', 'timestamp', ['null' => true, 'default' => null])
|
||||
->addColumn('updated_at', 'timestamp', ['null' => true, 'default' => null])
|
||||
->addIndex(['slug'], ['unique' => true, 'name' => 'events_slug_unique'])
|
||||
->addIndex(['status', 'starts_at'], ['name' => 'events_status_starts_at_index'])
|
||||
->addIndex(['user_id'], ['name' => 'events_user_id_index'])
|
||||
->addForeignKey('user_id', 'auth_users', 'id', [
|
||||
'delete' => 'SET_NULL',
|
||||
'update' => 'NO_ACTION',
|
||||
'constraint' => 'events_user_id_foreign',
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateEventBookingsTable extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$table = $this->table('event_bookings', [
|
||||
'id' => false,
|
||||
'primary_key' => ['id'],
|
||||
'engine' => 'InnoDB',
|
||||
'encoding' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
|
||||
$table
|
||||
->addColumn('id', 'biginteger', ['identity' => true, 'signed' => false])
|
||||
->addColumn('event_id', 'biginteger', ['signed' => false, 'null' => false])
|
||||
->addColumn('user_id', 'integer', ['signed' => false, 'null' => true, 'comment' => 'null = ospite non registrato'])
|
||||
->addColumn('name', 'string', ['limit' => 191, 'null' => false])
|
||||
->addColumn('email', 'string', ['limit' => 191, 'null' => false, 'comment' => 'raccolta contatti'])
|
||||
->addColumn('phone', 'string', ['limit' => 40, 'null' => true])
|
||||
->addColumn('seats', 'integer', ['signed' => false, 'null' => false, 'default' => 1])
|
||||
->addColumn('status', 'string', ['limit' => 20, 'null' => false, 'default' => 'pending', 'comment' => 'pending|confirmed|cancelled'])
|
||||
->addColumn('amount', 'decimal', ['precision' => 8, 'scale' => 2, 'null' => true, 'comment' => 'pronto per pagamenti'])
|
||||
->addColumn('token', 'string', ['limit' => 64, 'null' => false, 'comment' => 'gestione/annullo ospite via link email'])
|
||||
->addColumn('consent_at', 'datetime', ['null' => true, 'comment' => 'accettazione privacy/termini'])
|
||||
->addColumn('marketing_opt_in', 'char', ['limit' => 1, 'null' => false, 'default' => 'N', 'comment' => 'consenso marketing Y/N'])
|
||||
->addColumn('created_at', 'timestamp', ['null' => true, 'default' => null])
|
||||
->addColumn('updated_at', 'timestamp', ['null' => true, 'default' => null])
|
||||
->addIndex(['token'], ['unique' => true, 'name' => 'event_bookings_token_unique'])
|
||||
->addIndex(['event_id'], ['name' => 'event_bookings_event_id_index'])
|
||||
->addIndex(['email'], ['name' => 'event_bookings_email_index'])
|
||||
->addIndex(['user_id'], ['name' => 'event_bookings_user_id_index'])
|
||||
->addForeignKey('event_id', 'events', 'id', [
|
||||
'delete' => 'CASCADE',
|
||||
'update' => 'NO_ACTION',
|
||||
'constraint' => 'event_bookings_event_id_foreign',
|
||||
])
|
||||
->addForeignKey('user_id', 'auth_users', 'id', [
|
||||
'delete' => 'SET_NULL',
|
||||
'update' => 'NO_ACTION',
|
||||
'constraint' => 'event_bookings_user_id_foreign',
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddEventDefaultsToOptionTable extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('option')
|
||||
->addColumn('event_default_color', 'string', ['limit' => 7, 'null' => true, 'default' => '#4CAF50', 'after' => 'colorcancelled'])
|
||||
->addColumn('event_default_max_per_booking', 'integer', ['null' => false, 'default' => 1, 'after' => 'event_default_color'])
|
||||
->addColumn('event_notify_email', 'string', ['limit' => 191, 'null' => true, 'after' => 'event_default_max_per_booking'])
|
||||
->addColumn('event_terms_text', 'text', ['null' => true, 'after' => 'event_notify_email'])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddDetailsAndGalleryToEvents extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('events')
|
||||
->addColumn('instructions', 'text', ['null' => true, 'after' => 'description'])
|
||||
->addColumn('what_to_bring', 'text', ['null' => true, 'after' => 'instructions'])
|
||||
->addColumn('suitable_for', 'text', ['null' => true, 'after' => 'what_to_bring'])
|
||||
->addColumn('gallery', 'text', ['null' => true, 'comment' => 'JSON: array di path immagini', 'after' => 'suitable_for'])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddWaitlistToEvents extends AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('events')
|
||||
->addColumn('waitlist_enabled', 'char', [
|
||||
'limit' => 1,
|
||||
'null' => false,
|
||||
'default' => 'Y',
|
||||
'comment' => "Y = lista d'attesa quando pieno",
|
||||
'after' => 'max_per_booking'
|
||||
])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user