forked from k1LoW/tbls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.puml.tmpl
36 lines (32 loc) · 1.34 KB
/
schema.puml.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@startuml
{{ $sc := .showComment -}}
{{- $sd := .showDef -}}
!define table(name, desc) entity name as "desc" << (T,#5DBCD2) >>
!define view(name, desc) entity name as "desc" << (V,#C6EDDB) >>
!define column(name, type, desc) name <font color="#666666">[type]</font><font color="#333333">desc</font>
hide methods
hide stereotypes
skinparam class {
BackgroundColor White
BorderColor #6E6E6E
ArrowColor #6E6E6E
}
' tables
{{- range $i, $t := .Schema.Tables }}
{{- if ne $t.Type "VIEW" }}
table("{{ $t.Name }}", "{{ $t.Name }}{{ if $sc }}{{ if ne $t.Comment "" }}\n{{ $t.Comment | html | escape_nl }}{{ end }}{{ end }}") {
{{- else }}
view("{{ $t.Name }}", "{{ $t.Name }}{{ if $sc }}{{ if ne $t.Comment "" }}\n{{ $t.Comment | html | escape_nl }}{{ end }}{{ end }}") {
{{- end }}
{{- range $ii, $c := $t.Columns }}
{{- if $c.HideForER }}{{ continue }}{{ end }}
column("{{ if $c.PK}}+ {{ end }}{{ if $c.FK }}# {{ end }}{{ $c.Name | html }}", "{{ $c.Type | html }}", "{{ if $sc }}{{ if ne $c.Comment "" }} {{ $c.Comment | html | nl2space }}{{ end }}{{ end }}")
{{- end }}
}
{{- end }}
' relations
{{- range $j, $r := .Schema.Relations }}
{{- if $r.HideForER }}{{ continue }}{{ end }}
"{{ $r.Table.Name }}" {{ $r.Cardinality | lcardi }}--{{ $r.ParentCardinality | rcardi }} "{{ $r.ParentTable.Name }}" : "{{ if $sd }}{{ $r.Def | html }}{{ end }}"
{{- end }}
@enduml