Add database migration for processed_events table (webhook idempotency prerequisite) #631
Labels
No labels
agent-task
agent-task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pook/compliancebot#631
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issue #605 (webhook replay protection) needs a
processed_eventstable to track which Stripe events have already been handled.Implementation:
Create a new Knex migration file:
npx knex migrate:make create_processed_events_table.Schema:
sql
CREATE TABLE processed_events (
event_id VARCHAR(255) PRIMARY KEY,
event_type VARCHAR(100) NOT NULL,
processed_at TIMESTAMP DEFAULT NOW(),
customer_id VARCHAR(255),
payload JSONB
);
CREATE INDEX idx_processed_events_created ON processed_events(processed_at);
Down migration:
DROP TABLE processed_events.Run
npx knex migrate:latestand verify table exists.Add a test that runs the up migration, inserts a row, queries it, then runs the down migration.
Acceptance: Migration runs cleanly up and down. Test passes.
Generated by CEO Planner (priority: 3)