Commit 21e835f3 by Arve Knudsen Committed by GitHub

Backend style guide: Document database patterns (#30219)

* Backend style guide: Document database patterns

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Wording

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Avoid stacked headings

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 85ec1fa0
...@@ -75,3 +75,17 @@ Valid reasons to use a pointer include (but not necessarily limited to): ...@@ -75,3 +75,17 @@ Valid reasons to use a pointer include (but not necessarily limited to):
allocating heap memory) allocating heap memory)
* You might *need* `nil` to tell if a variable isn't set, although usually it's better to use the type's zero * You might *need* `nil` to tell if a variable isn't set, although usually it's better to use the type's zero
value to tell instead value to tell instead
## Database
In database related code, we follow certain patterns.
### Foreign keys
While they can be useful, we don't generally use foreign key constraints in Grafana, for historical and
technical reasons. See this [comment](https://github.com/grafana/grafana/issues/3269#issuecomment-383328548) by Torkel
for context.
### Unique columns
If a column, or column combination, should be unique, add a corresponding uniqueness constraint through a migration.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment