NAME

Punk::Model::PushSubscription - the subscriptions table

DESCRIPTION

Shipped so an application does not have to declare a model to use Punk::Plugin::Push. Declare your own under the same name and the plugin uses yours instead.

The DDL, for an application that manages its schema by hand:

CREATE TABLE push_subscriptions (
    id           SERIAL PRIMARY KEY,
    user_id      BIGINT NOT NULL,
    endpoint     TEXT NOT NULL UNIQUE,
    p256dh       TEXT NOT NULL,
    auth         TEXT NOT NULL,
    user_agent   TEXT,
    created_at   BIGINT NOT NULL,
    last_seen_at BIGINT,
    last_status  INTEGER
);
CREATE INDEX push_subscriptions_user ON push_subscriptions (user_id);

endpoint is unique and that is load-bearing: a browser re-subscribing produces the same endpoint, and without the constraint every re-subscribe adds a row and a single send fans out across the duplicates.

AUTHOR

LNATION <email@lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION <email@lnation.org>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)