29 lines
1.2 KiB
SQL
29 lines
1.2 KiB
SQL
CREATE TABLE `push_outbox` (
|
|
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
`dedupe_key` text NOT NULL,
|
|
`subscription_id` integer,
|
|
`payload` text NOT NULL,
|
|
`urgency` text DEFAULT 'normal' NOT NULL,
|
|
`status` text DEFAULT 'pending' NOT NULL,
|
|
`attempts` integer DEFAULT 0 NOT NULL,
|
|
`next_attempt_at` integer DEFAULT (cast(unixepoch('subsec') * 1000 as integer)) NOT NULL,
|
|
`error` text,
|
|
`created_at` integer DEFAULT (cast(unixepoch('subsec') * 1000 as integer)) NOT NULL,
|
|
`sent_at` integer,
|
|
FOREIGN KEY (`subscription_id`) REFERENCES `push_subscriptions`(`id`) ON UPDATE no action ON DELETE set null
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `push_outbox_dedupe_key_unique` ON `push_outbox` (`dedupe_key`);--> statement-breakpoint
|
|
CREATE TABLE `push_subscriptions` (
|
|
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
`user_id` integer NOT NULL,
|
|
`endpoint` text NOT NULL,
|
|
`p256dh` text NOT NULL,
|
|
`auth` text NOT NULL,
|
|
`user_agent` text,
|
|
`created_at` integer DEFAULT (cast(unixepoch('subsec') * 1000 as integer)) NOT NULL,
|
|
`last_ok_at` integer,
|
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `push_subscriptions_endpoint_unique` ON `push_subscriptions` (`endpoint`); |