diff --git a/output/dot/templates.go b/output/dot/templates.go index df3fe6a4..c69f9f56 100644 --- a/output/dot/templates.go +++ b/output/dot/templates.go @@ -6,8 +6,8 @@ import ( "github.com/jessevdk/go-assets" ) -var _Assets21532ae17ad95976ac467eeaeab81f2bb1d537e4 = "digraph \"{{ .Schema.Name }}\" {\n // Config\n graph [rankdir=TB, layout=dot, fontname=\"Arial\"];\n node [shape=record, fontsize=14, margin=0.6, fontname=\"Arial\"];\n edge [fontsize=10, labelfloat=false, splines=none, fontname=\"Arial\"];\n\n // Tables\n {{- range $i, $t := .Schema.Tables }}\n {{ $t.Name }} [shape=none, label=<\n \n {{- range $ii, $c := $t.Columns }}\n \n {{- end }}\n
{{ $t.Name | html }} [{{ $t.Type | html }}]
{{ $c.Name | html }} [{{ $c.Type | html }}]
>];\n {{- end }}\n\n // Relations\n {{- range $j, $r := .Schema.Relations }}\n {{ $r.Table.Name }}:{{ $c := index $r.Columns 0 }}{{ $c.Name }} -> {{ $r.ParentTable.Name }}:{{ $pc := index $r.ParentColumns 0 }}{{ $pc.Name }} [dir=back, arrowtail=crow, {{ if $r.IsAdditional }}style=\"dashed\",{{ end }} taillabel=<
{{ $r.Def | html }}
>];\n {{- end }}\n}\n" var _Assets5bd148e6149bb9adcdddfcf8cc46d6e3047dbe26 = "digraph {{ .Table.Name }} {\n // Config\n graph [rankdir=TB, layout=dot, fontname=\"Arial\"];\n node [shape=record, fontsize=14, margin=0.6, fontname=\"Arial\"];\n edge [fontsize=10, labelfloat=false, splines=none, fontname=\"Arial\"];\n\n // Tables\n {{ .Table.Name }} [shape=none, label=<\n \n {{- range $ii, $c := .Table.Columns }}\n \n {{- end }}\n
{{ .Table.Name | html }} [{{ .Table.Type | html }}]
{{ $c.Name | html }} [{{ $c.Type }}]
>];\n {{- range $i, $t := .Tables }}\n {{ $t.Name }} [shape=none, label=<\n \n {{- range $ii, $c := $t.Columns }}\n \n {{- end }}\n
{{ $t.Name | html }} [{{ $t.Type | html }}]
{{ $c.Name | html }} [{{ $c.Type | html }}]
>];\n {{- end }}\n\n // Relations\n {{- range $i, $r := .Relations }}\n {{ $r.Table.Name }}:{{ $c := index $r.Columns 0 }}{{ $c.Name }} -> {{ $r.ParentTable.Name }}:{{ $pc := index $r.ParentColumns 0 }}{{ $pc.Name }} [dir=back, arrowtail=crow, {{ if $r.IsAdditional }}style =\"dashed\",{{ end }} taillabel=<
{{ $r.Def | html }}
>];\n {{- end }}\n}\n" +var _Assets21532ae17ad95976ac467eeaeab81f2bb1d537e4 = "digraph \"{{ .Schema.Name }}\" {\n // Config\n graph [rankdir=TB, layout=dot, fontname=\"Arial\"];\n node [shape=record, fontsize=14, margin=0.6, fontname=\"Arial\"];\n edge [fontsize=10, labelfloat=false, splines=none, fontname=\"Arial\"];\n\n // Tables\n {{- range $i, $t := .Schema.Tables }}\n {{ $t.Name }} [shape=none, label=<\n \n {{- range $ii, $c := $t.Columns }}\n \n {{- end }}\n
{{ $t.Name | html }} [{{ $t.Type | html }}]
{{ $c.Name | html }} [{{ $c.Type | html }}]
>];\n {{- end }}\n\n // Relations\n {{- range $j, $r := .Schema.Relations }}\n {{ $r.Table.Name }}:{{ $c := index $r.Columns 0 }}{{ $c.Name }} -> {{ $r.ParentTable.Name }}:{{ $pc := index $r.ParentColumns 0 }}{{ $pc.Name }} [dir=back, arrowtail=crow, {{ if $r.IsAdditional }}style=\"dashed\",{{ end }} taillabel=<
{{ $r.Def | html }}
>];\n {{- end }}\n}\n" // Assets returns go-assets FileSystem var Assets = assets.NewFileSystem(map[string][]string{"/": []string{"schema.dot.tmpl", "table.dot.tmpl"}}, map[string]*assets.File{ diff --git a/output/md/templates.go b/output/md/templates.go index e7ed1afc..31903329 100644 --- a/output/md/templates.go +++ b/output/md/templates.go @@ -7,23 +7,23 @@ import ( ) var _Assets43889384df1c6f74d764c29d91b9d5637eb46061 = "# {{ .Schema.Name }}\n\n## Tables\n\n| Name | Columns | Comment | Type |\n| ---- | ------- | ------- | ---- |\n{{- range $i, $t := .Schema.Tables }}\n| [{{ $t.Name }}]({{ $t.Name }}.md) | {{ len $t.Columns }} | {{ $t.Comment }} | {{ $t.Type }} |\n{{- end }}\n\n{{ if .er -}}\n## Relations\n\n![er](schema.png)\n{{- end }}\n\n---\n\n> Generated by [tbls](https://github.com/k1LoW/tbls)" -var _Assetsac44302fb6150a621aa9d04a0350aac972bf7e18 = "# {{ .Table.Name }}\n\n## Description\n\n{{ .Table.Comment -}}\n{{ if .Table.Def }}\n
\n**Definition**\n\n```sql\n{{ .Table.Def }}\n```\n\n
\n{{ end }}\n\n## Columns\n\n| Name | Type | Default | Nullable | Children | Parents | Comment |\n| ---- | ---- | ------- | -------- | -------- | ------- | ------- |\n{{- range $i, $c := .Table.Columns }}\n| {{ $c.Name }} | {{ $c.Type }} | {{ $c.Default.String }} | {{ $c.Nullable }} | {{ range $ii, $r := $c.ChildRelations -}}[{{ $r.Table.Name }}]({{ $r.Table.Name }}.md) {{ end }} | {{ range $ii, $r := $c.ParentRelations -}}[{{ $r.ParentTable.Name }}]({{ $r.ParentTable.Name }}.md) {{ end }} | {{ $c.Comment }} |\n{{- end }}\n\n## Constraints\n\n| Name | Type | Def |\n| ---- | ---- | --- |\n{{- range $i, $c := .Table.Constraints }}\n| {{ $c.Name }} | {{ $c.Type }} | {{ $c.Def }} |\n{{- end }}\n\n## Indexes\n\n| Name | Def |\n| ---- | --- |\n{{- range $i, $idx := .Table.Indexes }}\n| {{ $idx.Name }} | {{ $idx.Def }} |\n{{- end }}\n\n{{ if .er -}}\n## Relations\n\n![er]({{ .Table.Name }}.png)\n{{- end }}\n\n---\n\n> Generated by [tbls](https://github.com/k1LoW/tbls)" +var _Assetsac44302fb6150a621aa9d04a0350aac972bf7e18 = "# {{ .Table.Name }}\n\n## Description\n\n{{ .Table.Comment -}}\n{{ if .Table.Def }}\n
\nTable Definition\n\n```sql\n{{ .Table.Def }}\n```\n\n
\n{{ end }}\n\n## Columns\n\n| Name | Type | Default | Nullable | Children | Parents | Comment |\n| ---- | ---- | ------- | -------- | -------- | ------- | ------- |\n{{- range $i, $c := .Table.Columns }}\n| {{ $c.Name }} | {{ $c.Type }} | {{ $c.Default.String }} | {{ $c.Nullable }} | {{ range $ii, $r := $c.ChildRelations -}}[{{ $r.Table.Name }}]({{ $r.Table.Name }}.md) {{ end }} | {{ range $ii, $r := $c.ParentRelations -}}[{{ $r.ParentTable.Name }}]({{ $r.ParentTable.Name }}.md) {{ end }} | {{ $c.Comment }} |\n{{- end }}\n\n## Constraints\n\n| Name | Type | Def |\n| ---- | ---- | --- |\n{{- range $i, $c := .Table.Constraints }}\n| {{ $c.Name }} | {{ $c.Type }} | {{ $c.Def }} |\n{{- end }}\n\n## Indexes\n\n| Name | Def |\n| ---- | --- |\n{{- range $i, $idx := .Table.Indexes }}\n| {{ $idx.Name }} | {{ $idx.Def }} |\n{{- end }}\n\n{{ if .er -}}\n## Relations\n\n![er]({{ .Table.Name }}.png)\n{{- end }}\n\n---\n\n> Generated by [tbls](https://github.com/k1LoW/tbls)" // Assets returns go-assets FileSystem var Assets = assets.NewFileSystem(map[string][]string{"/": []string{"index.md.tmpl", "table.md.tmpl"}}, map[string]*assets.File{ - "/": &assets.File{ + "/table.md.tmpl": &assets.File{ + Path: "/table.md.tmpl", + FileMode: 0x1a4, + Mtime: time.Unix(1528198538, 1528198538000000000), + Data: []byte(_Assetsac44302fb6150a621aa9d04a0350aac972bf7e18), + }, "/": &assets.File{ Path: "/", FileMode: 0x800001ed, - Mtime: time.Unix(1528198425, 1528198425000000000), + Mtime: time.Unix(1528198538, 1528198538000000000), Data: nil, }, "/index.md.tmpl": &assets.File{ Path: "/index.md.tmpl", FileMode: 0x1a4, Mtime: time.Unix(1527684406, 1527684406000000000), Data: []byte(_Assets43889384df1c6f74d764c29d91b9d5637eb46061), - }, "/table.md.tmpl": &assets.File{ - Path: "/table.md.tmpl", - FileMode: 0x1a4, - Mtime: time.Unix(1528198425, 1528198425000000000), - Data: []byte(_Assetsac44302fb6150a621aa9d04a0350aac972bf7e18), }}, "") diff --git a/output/md/templates/table.md.tmpl b/output/md/templates/table.md.tmpl index ee98b511..c3627099 100644 --- a/output/md/templates/table.md.tmpl +++ b/output/md/templates/table.md.tmpl @@ -5,7 +5,7 @@ {{ .Table.Comment -}} {{ if .Table.Def }}
-**Definition** +Table Definition ```sql {{ .Table.Def }} diff --git a/sample/mysql/post_comments.md b/sample/mysql/post_comments.md index a90b0f33..cb4d4080 100644 --- a/sample/mysql/post_comments.md +++ b/sample/mysql/post_comments.md @@ -4,7 +4,7 @@ post and comments View table
-**Definition** +Table Definition ```sql (select `c`.`id` AS `id`,`p`.`title` AS `title`,`u2`.`username` AS `post_user`,`c`.`comment` AS `comment`,`u2`.`username` AS `comment_user`,`c`.`created` AS `created`,`c`.`updated` AS `updated` from (((`testdb`.`posts` `p` left join `testdb`.`comments` `c` on((`p`.`id` = `c`.`post_id`))) left join `testdb`.`users` `u` on((`u`.`id` = `p`.`user_id`))) left join `testdb`.`users` `u2` on((`u2`.`id` = `c`.`user_id`)))) diff --git a/sample/mysql8/post_comments.md b/sample/mysql8/post_comments.md index edbffba6..0a586da0 100644 --- a/sample/mysql8/post_comments.md +++ b/sample/mysql8/post_comments.md @@ -4,7 +4,7 @@ post and comments View table
-**Definition** +Table Definition ```sql select `c`.`id` AS `id`,`p`.`title` AS `title`,`u2`.`username` AS `post_user`,`c`.`comment` AS `comment`,`u2`.`username` AS `comment_user`,`c`.`created` AS `created`,`c`.`updated` AS `updated` from (((`testdb`.`posts` `p` left join `testdb`.`comments` `c` on((`p`.`id` = `c`.`post_id`))) left join `testdb`.`users` `u` on((`u`.`id` = `p`.`user_id`))) left join `testdb`.`users` `u2` on((`u2`.`id` = `c`.`user_id`))) diff --git a/sample/postgres/post_comments.md b/sample/postgres/post_comments.md index 32479dce..4e9b339c 100644 --- a/sample/postgres/post_comments.md +++ b/sample/postgres/post_comments.md @@ -4,7 +4,7 @@ post and comments View table
-**Definition** +Table Definition ```sql SELECT c.id,