-
Notifications
You must be signed in to change notification settings - Fork 0
Schemas
Following the PostgREST approach, SmoothDB allows you to specify which schema to use on a per-call basis via headers:
-
Accept-Profilefor GET and HEAD requests -
Content-Profilefor POST, PUT, PATCH, and DELETE requests
If a schema is not specified, SmoothDB defaults to the first schema configured in Database.SchemaSearchPath.
Similarly, PostgREST defaults to the first schema configured in
dbschemas.
Since SmoothDB also supports administering databases with DDL commands, this schema selection logic will apply to those commands as well. Work is currently in progress to fully implement this feature.
Until version 0.2.6, SmoothDB accepted a full table name in most of its DDL commands, i.e., a table name with an optional schema name, using the classic SQL format <schema>.<table> (and <schema>.<function>, etc.). The approach had the limit that, as implemented, did not support table names with dots.
In the current revision, the schema name has been explicitly added to all database structures.
Furthermore, DDL requests, like normal requests, now accept the schema using the Accept-Profile and Content-Profile headers.
Examples:
- CreateTable: This command will consider the schema from the field in the struct, the profile header, and the default schema, in this order.
- UpdateTable: Since this command does not have an input struct, it will consider the schema from the profile header and the default schema, in this order.
The current mode seems reasonable, but perhaps we should considering accepting full table names in the future, considering also the case that a table name may cointain dots (ie schema."table.with.dots")