News for hackers. Stuff that matters.
Re:PostgREST by dragonwriter on Sunday November 03, 2019 @11:57PM (#21439147)
> You probably would need to adopt a rule of no direct-to-table access

That's like one of the oldest RDBMS best practices: no direct to table access, with every application (or class of business user with direct access to the DB) having access through a tailored selection of views so that apps/users are largely isolated from DB changes.

> and a separate schema per API version containing views

You'd probably only need a separate schema for semver-major API versions, minor versions would necessarily be supersets which could be accommodate by backwards-compatible schema extension.

> and dealing with the pain of rewriting the views for all the supported API versions when you need to change your data model.

With a well-designed normalized relational model, most changes to the base model are adding attributes or tables, which will have zero impact on view definitions to maintain an existing API. The next most common is factoring an existing attribute out to a different table because what was conceived of as a 1:1 relationship becomes 1:N, which requires adding a join to view defs where that attribute is involved.

Re:PostgREST by toyg on Monday November 04, 2019 @08:44AM (#21441512)
It’s funny how “best practices” get mirrored basically everywhere up and down the stack. Everything at some point will have some way of decoupling data-access and data-structure, you just choose the level you want to do it at (toolkit, ORM, network api, database, schema/view, tablespace, filesystem...) and the number and granularity of layers, picking what you are most comfortable with.

It’s like, no matter how low-level you go, at some point someone had a problem with components being tightly coupled and introduced an indirection layer “for next time”.

Re:PostgREST by andrey_utkin on Monday November 04, 2019 @04:13AM (#21440002)
How do you deal with writing operations in this approach?
Re:PostgREST by dragonwriter on Monday November 04, 2019 @04:39AM (#21440115)
> How do you deal with writing operations in this approach?

The same as read operations, with views, which can be, in Postgres, automatically updatable if they are a simple thin layer over base tables, and otherwise can be made updatable by means of appropriate triggers defining the meaning of INSERT/UPDATE/DELETE on them just as the view definition defines the meaning of SELECT.