Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/wh/migrations/0002_delivery-sent-tracking.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP INDEX `delivery_tunnel_delivery_idx`;--> statement-breakpoint
ALTER TABLE `delivery` ADD `sent_at` integer;--> statement-breakpoint
CREATE INDEX `delivery_tunnel_delivery_idx` ON `delivery` (`tunnel_id`,`delivered_at`,`sent_at`,`failed_at`,`received_at`);
230 changes: 230 additions & 0 deletions apps/wh/migrations/meta/0002_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"version": "6",
"dialect": "sqlite",
"id": "2fedf88b-a3db-4453-9423-6665b7180078",
"prevId": "617459ed-59ef-4877-b22e-cad7fe84b2f4",
"tables": {
"delivery": {
"name": "delivery",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"tunnel_id": {
"name": "tunnel_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"method": {
"name": "method",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"headers": {
"name": "headers",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"body": {
"name": "body",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"received_at": {
"name": "received_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"sent_at": {
"name": "sent_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"delivered_at": {
"name": "delivered_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"failed_at": {
"name": "failed_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"error": {
"name": "error",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"delivery_tunnel_delivery_idx": {
"name": "delivery_tunnel_delivery_idx",
"columns": [
"tunnel_id",
"delivered_at",
"sent_at",
"failed_at",
"received_at"
],
"isUnique": false
}
},
"foreignKeys": {
"delivery_tunnel_id_tunnel_id_fk": {
"name": "delivery_tunnel_id_tunnel_id_fk",
"tableFrom": "delivery",
"tableTo": "tunnel",
"columnsFrom": [
"tunnel_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"tunnel": {
"name": "tunnel",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"device_token_hash": {
"name": "device_token_hash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_id": {
"name": "provider_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"environment": {
"name": "environment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_account_id": {
"name": "provider_account_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_webhook_endpoint_id": {
"name": "provider_webhook_endpoint_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'active'"
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"last_seen_at": {
"name": "last_seen_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"disabled_at": {
"name": "disabled_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"tunnel_device_provider_unique": {
"name": "tunnel_device_provider_unique",
"columns": [
"device_token_hash",
"provider_id",
"environment",
"provider_account_id"
],
"isUnique": true
},
"tunnel_device_idx": {
"name": "tunnel_device_idx",
"columns": [
"device_token_hash"
],
"isUnique": false
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
9 changes: 8 additions & 1 deletion apps/wh/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"when": 1778238601783,
"tag": "0001_delivery-failure-tracking",
"breakpoints": true
},
{
"idx": 2,
"version": "6",
"when": 1778501327588,
"tag": "0002_delivery-sent-tracking",
"breakpoints": true
}
]
}
}
6 changes: 3 additions & 3 deletions apps/wh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"type": "module",
"scripts": {
"dev": "wrangler dev --local",
"deploy": "if [ -z \"$PAYKIT_WEBHOOK_API_BASE_URL\" ]; then printf '%s\n' 'Missing PAYKIT_WEBHOOK_API_BASE_URL'; exit 1; fi; wrangler deploy --var \"PAYKIT_WEBHOOK_API_BASE_URL:$PAYKIT_WEBHOOK_API_BASE_URL\"",
"db:migrate:local": "wrangler d1 migrations apply paykit-wh --local",
"db:migrate:remote": "wrangler d1 migrations apply paykit-wh --remote",
"deploy": "if [ -z \"${PAYKIT_WEBHOOK_PUBLIC_BASE_URL:-$PAYKIT_WEBHOOK_API_BASE_URL}\" ]; then printf '%s\n' 'Missing PAYKIT_WEBHOOK_PUBLIC_BASE_URL'; exit 1; fi; wrangler deploy --var \"PAYKIT_WEBHOOK_PUBLIC_BASE_URL:${PAYKIT_WEBHOOK_PUBLIC_BASE_URL:-$PAYKIT_WEBHOOK_API_BASE_URL}\"",
"db:migrate:local": "wrangler d1 migrations apply DB --local",
"db:migrate:remote": "wrangler d1 migrations apply DB --remote",
"db:studio": "drizzle-kit studio --config drizzle.config.ts",
"ship": "bun run db:migrate:remote && bun run deploy",
"typecheck": "tsc --noEmit"
Expand Down
2 changes: 2 additions & 0 deletions apps/wh/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const delivery = sqliteTable(
headers: text("headers", { mode: "json" }).$type<Record<string, string>>().notNull(),
body: text("body").notNull(),
receivedAt: integer("received_at", { mode: "number" }).notNull(),
sentAt: integer("sent_at", { mode: "number" }),
deliveredAt: integer("delivered_at", { mode: "number" }),
failedAt: integer("failed_at", { mode: "number" }),
error: text("error"),
Expand All @@ -46,6 +47,7 @@ export const delivery = sqliteTable(
index("delivery_tunnel_delivery_idx").on(
table.tunnelId,
table.deliveredAt,
table.sentAt,
table.failedAt,
table.receivedAt,
),
Expand Down
Loading
Loading