Re: Modeling database

From: James Keener <jim(at)jimkeener(dot)com>
To: pgsql-novice(at)lists(dot)postgresql(dot)org, Norton Glitz <norton(dot)glitz(at)gmail(dot)com>
Subject: Re: Modeling database
Date: 2021-10-16 15:56:07
Message-ID: 71D13FFB-64FF-4412-8AB0-D03B56CA4644@jimkeener.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I wouldn't automatically remove/disabled anything without the user choosing.

You could have a before trigger that will fail if the new plan has fewer ads than they currently have active. You can return an error message when you `raise` the error that the application can use to notify the user that they need to choose which ads to disable before downgrading their account.

Jim

On October 15, 2021 9:51:21 PM EDT, Norton Glitz <norton(dot)glitz(at)gmail(dot)com> wrote:
>Hello,
>
>In my site users will choose one subscription to have a certain amount of
>properties to advertise.
>
>For example, if he bought a subscription with 5 ads, he can advertise 3
>houses and 2 apartments.
>
>The user can also modify the subscription, for like 10 ads. Now the same
>user can advertise 5 more properties. But he can also decrease the amount
>of ads, for example 2. But in this case he will have already more than 2
>ads running.
>
>Is there a way for everytime the subscription changes, if he has more ads
>than the subscription allows it just turn off the amount that is more than
>hired?
>
>I'm not sure how to model this problem yet. Any answer would be awesome.
>
>Thank you

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Agil Azimov 2021-10-19 07:38:17 Re: Password settings requirements
Previous Message Norton Glitz 2021-10-16 01:51:21 Modeling database