User guide¶
This guide will use one main over-arching example as a way to walk through everything DbDeclare can do. Some details are omitted as they are unnecessary for the example, and some are contrived to show more functionality.
The example¶
Let's say we have an application that takes in articles from a variety of news sites, clusters them, and exposes
the clusters via an API. We also want to store API logs (yes, this is typically not done in tables in Postgres, please
bear with me for the sake of the example). We want to accommodate 3 stages in our cluster: test, dev, and prod
(yes, it is typically best practice to have prod in a completely separate cluster/instance, but
humor me for this example). So for each stage, we want the following:
- Schemas and tables:
- In the
defaultschema, tables for:Article,Keyword,Cluster - In a
logschema, tables for:BadRequest,GoodRequest
- In the
- Groups (roles that will not log in but define privileges):
- An
etl_writerrole that can insert and update onArticleandKeyword - A
ml_writerrole that can insert and update onCluster - A
readerrole that can select onArticle,Keyword, andCluster - A
logrole that can insert, update, and select onBadRequestandGoodRequest(omit fortest)
- An
- Users (roles that will log in):
- An
etlrole that is a member ofetl_writerandreader - An
mlrole that is a member ofml_writerandreader - An
apirole that is a member oflogandreader(omit fortest)
- An
Sound like a lot? No worries, we'll take it step by step. Let's start with our databases. If this seems straightforward, and you'd prefer to just see the entire example, skip ahead.