Add multiple DB schema support for bal persist proposal #1328
+164
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Many database providers allow you to organize database tables into named groups. You can use this to make the logical structure of the data model easier to understand or to avoid naming collisions between tables. These groups are known as schemas in PostgreSQL, CockroachDB, and SQL Server.
This proposal introduces support for connecting to tables in multiple database schemas in
bal persist
. Right now,bal persist
only supports connecting to tables in the default schema of the database. However, in real-world scenarios, tables are often distributed across multiple schemas in the database. When working with such existing databases, it is essential to provide a way to explicitly represent the schema of the table in the model file.Goals
bal persist
API.Approach
The current
bal persist
model supports the following annotations to map the model to a different table name in the database. For example, the following model will be mapped to thepatients
table in the database.This proposal introduces a new annotation to map the model to a different schema in the database. For example, the following model will be mapped to the
patients
table in thehealthcare
schema in the database.Related issues: #1327