PostgREST / postgrest-docs

This repo is archived and will be merged into postgrest/postgrest soon.
http://postgrest.org
MIT License
365 stars 164 forks source link

Having more than one internal schema on schema isolation is confusing #736

Open steve-chavez opened 5 months ago

steve-chavez commented 5 months ago

Problem

Related to https://postgrest.org/en/stable/explanations/schema_isolation.html

See: https://matrix.to/#/!YGChDzXeYxtlBZqVsc:gitter.im/$V_mpHPVIPg_QJ2YMWWu7s3K5d1_WGmbcBwrdm2oaRxU?via=gitter.im&via=matrix.org&via=matrix.freyachat.eu

A PostgREST instance exposes all the tables, views, and stored procedures of a single PostgreSQL schema(a namespace of database objects). This means private data or implementation details can go I think I understand using an 'api' as the schema that is exposed to the outside work. It makes sense to have a separate schema for the actual implementation. I do not understand why you would have more than one (core + internal + private). ... more that one implementation schema. My assumption is that "core", "internal" and "private" are just examples of names where your implementation would go. Is this correct?

Solution

Just have one internal schema. Maybe add another one for "extensions".

cboecking commented 5 months ago

Thank you! Here are my ignorant thoughts regarding what makes sense to me:

wolfgangwalther commented 5 months ago

In my projects, I have settled on 5 schemas:

I think those three schemas (four including data) should be represented in the "schema isolation" part, because they are needed to understand the differences between db-schemas, db-extra-search-path and purely internal schemas.

Maybe add another one for "extensions".

Each extension has it's own schema for me. That means it's immediately clear whenever I call a function from an extension, because it will always be prefixed with the extension's name.

cboecking commented 5 months ago

One quick question I have is how to manage different versions of an API. Here is my assumption:

I am including this thought in this thread because the assumption is that we can separate versions in different schemas.

I believe this works if you adopt the practice of where you allow the public/exposted versions of the schema to introduce breaking changes; however, you ensure the private schema does not break any actively supported public schema versions.

Curious to hear thoughts... Chuck

wolfgangwalther commented 5 months ago

One quick question I have is how to manage different versions of an API.

I have not found a satisfying answer to that, yet.

I am including this thought in this thread because the assumption is that we can separate versions in different schemas.

Yes, absolutely. That makes a lot of sense.

I believe this works if you adopt the practice of where you allow the public/exposted versions of the schema to introduce breaking changes; however, you ensure the private schema does not break any actively supported public schema versions.

Right.

Also mentioned here: #69. A slightly different approach is discussed in https://github.com/PostgREST/postgrest/issues/2166.