Add database migration for processed_events table (webhook idempotency prerequisite) #631

Open
opened 2026-04-11 06:53:31 -04:00 by pook · 0 comments
Owner

Issue #605 (webhook replay protection) needs a processed_events table to track which Stripe events have already been handled.

Implementation:

  1. Create a new Knex migration file: npx knex migrate:make create_processed_events_table.

  2. 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);

  3. Down migration: DROP TABLE processed_events.

  4. Run npx knex migrate:latest and verify table exists.

  5. 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)

Issue #605 (webhook replay protection) needs a `processed_events` table to track which Stripe events have already been handled. Implementation: 1. Create a new Knex migration file: `npx knex migrate:make create_processed_events_table`. 2. 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); 3. Down migration: `DROP TABLE processed_events`. 4. Run `npx knex migrate:latest` and verify table exists. 5. 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)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#631
No description provided.