collab: Keep track of last seen Stripe event for each record (#15480)
This PR improves our Stripe event handling by keeping track of the last event we've seen for each record. The `billing_customers` and `billing_subscriptions` tables both have a new `last_stripe_event_id` column. When we apply an event to one of these records, we store the event ID that was applied. Then, when we are going through events we can ignore any event that has an ID that came before the `last_stripe_event_id` (based on the lexicographical ordering of the IDs). Release Notes: - N/A
This commit is contained in:
parent
2ada2964c5
commit
b160e13f20
9 changed files with 253 additions and 34 deletions
|
@ -422,7 +422,8 @@ CREATE TABLE IF NOT EXISTS billing_subscriptions (
|
|||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
billing_customer_id INTEGER NOT NULL REFERENCES billing_customers(id),
|
||||
stripe_subscription_id TEXT NOT NULL,
|
||||
stripe_subscription_status TEXT NOT NULL
|
||||
stripe_subscription_status TEXT NOT NULL,
|
||||
last_stripe_event_id TEXT
|
||||
);
|
||||
|
||||
CREATE INDEX "ix_billing_subscriptions_on_billing_customer_id" ON billing_subscriptions (billing_customer_id);
|
||||
|
@ -432,7 +433,8 @@ CREATE TABLE IF NOT EXISTS billing_customers (
|
|||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
user_id INTEGER NOT NULL REFERENCES users(id),
|
||||
stripe_customer_id TEXT NOT NULL
|
||||
stripe_customer_id TEXT NOT NULL,
|
||||
last_stripe_event_id TEXT
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX "uix_billing_customers_on_user_id" ON billing_customers (user_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue