forked from k1LoW/tbls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.puml.tmpl
46 lines (42 loc) · 1.96 KB
/
table.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
37
38
39
40
41
42
43
44
45
46
@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
{{- if ne .Table.Type "VIEW" }}
table("{{ .Table.Name }}", "{{ .Table.Name }}{{ if $sc }}{{ if ne .Table.Comment "" }}\n{{ .Table.Comment | html | escape_nl }}{{ end }}{{ end }}") {
{{- else }}
view("{{ .Table.Name }}", "{{ .Table.Name }}{{ if $sc }}{{ if ne .Table.Comment "" }}\n{{ .Table.Comment | html | escape_nl }}{{ end }}{{ end }}") {
{{- end }}
{{- range $i, $c := .Table.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 }}
}
{{- range $i, $t := .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 := .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