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(); } }