Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Recommend using views for abstraction, but don't enforce it from the beginning #531

Open
steve-chavez opened this issue May 4, 2022 · 0 comments
Labels
explanations background and context about how the project works.

Comments

@steve-chavez
Copy link
Member

Currently on https://postgrest.org/en/latest/schema_structure.html#schema-isolation

It is recommended that you don’t expose tables on your API schema. Instead expose views and stored procedures which insulate the internal details from the outside world.

We recommend wrapping all tables in views from the get-go, however that has a considerable maintenance impact(more db objects) specially at the beginning of a project. There's nothing wrong in doing:

-- moving a table to a private schema and replacing it by a view
BEGIN;
ALTER TABLE api.projects SET SCHEMA private;
CREATE VIEW api.projects AS SELECT * FROM private.projects;
END;

At later stages of the project if some abstraction is needed.

Most real world cases have a combination of tables and views.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
explanations background and context about how the project works.
Development

No branches or pull requests

1 participant