Search code examples
postgresqlhasura

How to store tempory data in hasura/postgresql database?


How do I store temporary data in hasura/my postgresql database? My usecase is for verificaion codes during onboarding (for example, email) which I don't want to have afterwards in the schema. (otherwise I'd have verification_x, verification_y, etc etc etc)


Solution

  • This is more of a DB feature than a hasura thing.

    The short answer is, no. This is not a feature of Postgres or Hasura. You can implement it relatively easily if you need to.

    See this answer for a Postgres trigger based solution and for a comment downvoting this idea. Hasura also has event triggers if you are more comfortable using a language like python or JS to implement this logic. Basically, an expiration (timestamp) column will allow you to determine when a record is expired. If (or how often) you choose to physically query and delete the expired records is your decision.