Database triggers for subscription upgrade


I believe my use case is very basic but I can’t make this work.

Context: I’ve 3 pricing plan, user pays with stripe, there’s a webbook in my app that listens to any pricing plan change made by the user in the customer portal.

Problem: I want that, when the user upgrades their plan, they are granted 5000 credits (make a change to the user, credit = 5000). I’m trying to trigger this with data base event. My plan was to try the following:


The issue is that it has no impact.

I saw the usual database trigger is something like “thing of before” is not “thing of now”, which doesn’t work for a situation where users can switch between 3 pricing plans (you don’t want to grant more credits to someone who downgraded)

Do you know how I would implement this right?



Hi @tris

I see that ““thing of before” is not “thing of now”” will not work for you.

Have you considered adding a field called plan_level?
So, your Free plan would be plan level “1”, next upgraded plan would be plan_level “2”, incrementing all the way upto your highest plan_level “n”
Then you would define your trigger in this way:
“user before change’s Plan_level” < “user after change’s Plan_level”
This would mean that if you ended up adding more tiers to your pricing, and as a user if i upgrade from tier 2 to tier 5, this trigger would still work.

Coming to “The issue is that it has no impact”, do you mean the DB trigger does not trigger when it is supposed to?
I tend to troubleshoot this by creating a test table where every time my plan_level plan_type/required trigger field is updated, I log those changes in test table.
At the end of which i have a list of times and actions where the value was updated and yet trigger did not run. This would help you to find a pattern or would atleast be easy to share with bubble team , in case it is a bug.

Hi @maindola.yogini

I appreciate your suggestion.

I don’t know how to track the plan level in case the user changes plan with the stripe customer portal.

I currently use an API workflow that changes the “plan type” field, looking for Request’s object plan id (the id of the stripe plan), this effectively changes the code of the stripe plan associated to the user.

This is why I was using “plan type” in the previous screenshot. But if I use 1, 2, 3. i can assign these values upon subscription with a make change to user workflow for sure but I don’t know how to tell my app the customer went from 1 to 2 in stripe.

When I mean no impact, I mean that the database trigger action doesn’t make the change to the current user I’m requesting (i.e. passing the user from 25 credits to 5000 if they had plan x before and switched to plan y).

How do you make sure the change made in the stripe customer portal is “sent back” to your app?

Thanks for the help though