Files
yogibook_aury_new/db/migrations/20260812200300_create_notificationlog_table.php
2026-08-15 12:00:28 +03:00

54 lines
1.8 KiB
PHP

<?php
use Phinx\Migration\AbstractMigration;
final class CreateNotificationlogTable extends AbstractMigration
{
public function change(): void
{
$this->table('notificationlog', ['id' => 'idnotificationlog'])
->addColumn('iduser', 'integer', [
'null' => false,
'comment' => 'auth_users.id',
])
->addColumn('notificationtype', 'string', [
'limit' => 30,
'null' => false,
'comment' => 'lesson / order / certificate',
])
->addColumn('idreference', 'integer', [
'null' => false,
'comment' => 'Id della lezione, ordine o certificato',
])
->addColumn('daysbefore', 'integer', [
'null' => false,
'default' => 0,
])
->addColumn('sent_at', 'datetime', [
'default' => 'CURRENT_TIMESTAMP',
'null' => false,
])
->addColumn('status', 'string', [
'limit' => 20,
'null' => false,
'default' => 'sent',
'comment' => 'sent / failed',
])
->addColumn('devicecount', 'integer', [
'null' => false,
'default' => 0,
'comment' => 'A quanti dispositivi e stata inviata',
])
->addColumn('errormessage', 'string', [
'limit' => 255,
'null' => true,
])
->addIndex(
['iduser', 'notificationtype', 'idreference', 'daysbefore'],
['unique' => true, 'name' => 'uq_notificationlog_invio']
)
->addIndex(['sent_at'], ['name' => 'idx_notificationlog_data'])
->create();
}
}