Implementing State Machines in PostgreSQL | Hacker News