Store the Push Subscription in the database

This commit is contained in:
Alex Gleason
2024-10-02 22:20:47 -05:00
parent 049d99af9b
commit 4561ec0d00
4 changed files with 56 additions and 20 deletions

View File

@@ -59,6 +59,7 @@ interface EventZapRow {
interface PushSubscriptionRow {
id: Generated<bigint>;
pubkey: string;
token_hash: Uint8Array;
endpoint: string;
p256dh: string;
auth: string;

View File

@@ -5,7 +5,7 @@ export async function up(db: Kysely<any>): Promise<void> {
.createTable('push_subscriptions')
.addColumn('id', 'bigint', (c) => c.primaryKey().autoIncrement())
.addColumn('pubkey', 'char(64)', (c) => c.notNull())
.addColumn('token', 'char(64)', (c) => c.notNull())
.addColumn('token_hash', 'bytea', (c) => c.references('auth_tokens.token_hash').onDelete('cascade').notNull())
.addColumn('endpoint', 'text', (c) => c.notNull())
.addColumn('p256dh', 'text', (c) => c.notNull())
.addColumn('auth', 'text', (c) => c.notNull())