This... does not seem like separation of concerns.
Not to mention that the data layer seems like the one where you want to keep things most deterministic.
Not to mention that the data layer seems like the one where you want to keep things most deterministic.
Don't get me wrong, I like the idea and all that, but this is another pgsql "solution" that is tied to the database layer, when it should be in the application layer.
I like to be database agnostic, and while I prefer PostgreSQL on production, I prefer SQLite on the dev layer. You should never have to HAVE TO use a specific database to make your APPLICATION work.