Home > OS >  How to modify DB field on a given date, if this field depends on another field
How to modify DB field on a given date, if this field depends on another field

Time:04-10

Java, Spring, PostgresDB

I want to set TRUE isActive column in the Subscription table automatically, if the subscriptionStartDate hits the actual date. A scheduled task to check the startDate every subscription every day seems to be little raw solution (but maybe the only). Any better solution?

CodePudding user response:

You are requesting to mutate the value of a column without explicitly require the database change. This is not supported by PostgresDB/MySQL. With this approach some scheduled task is required.

Although you can take a different approach, when you retrieve the records you can search by subscriptionStartDate <= now() which will get all subscriptions that are currently active.

  • Related