Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

0002_violet_lionheart.sql

36 lines1.5 KB

1CREATE TABLE `cache_meta` (
2 `key` text PRIMARY KEY NOT NULL,
3 `fetched_at` integer NOT NULL,
4 `stale_time` integer NOT NULL,
5 `last_error` text,
6 `refreshing` integer DEFAULT false NOT NULL
7);
8--> statement-breakpoint
9CREATE TABLE `subscriptions` (
10 `id` text PRIMARY KEY NOT NULL,
11 `agent_id` text NOT NULL,
12 `url` text NOT NULL,
13 `secret` text NOT NULL,
14 `events` text NOT NULL,
15 `provider_filter` text,
16 `active` integer DEFAULT true NOT NULL,
17 `created_at` integer NOT NULL,
18 FOREIGN KEY (`agent_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,
19 FOREIGN KEY (`provider_filter`) REFERENCES `providers`(`id`) ON UPDATE no action ON DELETE cascade
20);
21--> statement-breakpoint
22CREATE INDEX `subscriptions_agentId_idx` ON `subscriptions` (`agent_id`);--> statement-breakpoint
23CREATE TABLE `webhook_deliveries` (
24 `id` text PRIMARY KEY NOT NULL,
25 `subscription_id` text NOT NULL,
26 `change_id` text NOT NULL,
27 `attempt` integer DEFAULT 0 NOT NULL,
28 `next_attempt_at` integer NOT NULL,
29 `status` text DEFAULT 'pending' NOT NULL,
30 `last_response_code` integer,
31 FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions`(`id`) ON UPDATE no action ON DELETE cascade,
32 FOREIGN KEY (`change_id`) REFERENCES `changes`(`id`) ON UPDATE no action ON DELETE cascade
33);
34--> statement-breakpoint
35CREATE INDEX `webhook_deliveries_status_nextAttemptAt_idx` ON `webhook_deliveries` (`status`,`next_attempt_at`);--> statement-breakpoint
36CREATE INDEX `webhook_deliveries_subscriptionId_idx` ON `webhook_deliveries` (`subscription_id`);