diff --git a/cmd/doc.go b/cmd/doc.go index d4273e15a..a2d44cf6a 100644 --- a/cmd/doc.go +++ b/cmd/doc.go @@ -23,9 +23,13 @@ package cmd import ( "fmt" "github.com/k1LoW/tbls/db" + "github.com/k1LoW/tbls/output/dot" "github.com/k1LoW/tbls/output/md" + "github.com/k1LoW/tbls/schema" "github.com/spf13/cobra" "os" + "os/exec" + "path/filepath" ) // docCmd represents the doc command @@ -64,13 +68,16 @@ var docCmd = &cobra.Command{ } } - switch outputFormat { - case "md": - err = md.Output(s, outputPath, force) - default: - err = fmt.Errorf("Error: %s", "unsupported output format") + _, err = exec.Command("which", "dot").Output() + if err == nil { + err := withDot(s, outputPath) + if err != nil { + fmt.Println(err) + } } + err = md.Output(s, outputPath, force) + if err != nil { fmt.Println(err) os.Exit(1) @@ -78,10 +85,46 @@ var docCmd = &cobra.Command{ }, } +// withDot ... +func withDot(s *schema.Schema, outputPath string) error { + fullPath, err := filepath.Abs(outputPath) + if err != nil { + return err + } + fmt.Printf("%s\n", filepath.Join(outputPath, "schema.png")) + c := exec.Command("dot", "-Tpng", "-o", filepath.Join(fullPath, "schema.png")) + stdin, _ := c.StdinPipe() + err = dot.OutputSchema(stdin, s) + if err != nil { + return err + } + stdin.Close() + err = c.Run() + if err != nil { + return err + } + // tables + for _, t := range s.Tables { + fmt.Printf("%s\n", filepath.Join(outputPath, fmt.Sprintf("%s.png", t.Name))) + c := exec.Command("dot", "-Tpng", "-o", filepath.Join(fullPath, fmt.Sprintf("%s.png", t.Name))) + stdin, _ := c.StdinPipe() + err = dot.OutputSchema(stdin, s) + if err != nil { + return err + } + stdin.Close() + err = c.Run() + if err != nil { + return err + } + } + + return nil +} + func init() { rootCmd.AddCommand(docCmd) docCmd.Flags().BoolVarP(&force, "force", "f", false, "force") docCmd.Flags().BoolVarP(&sort, "sort", "", false, "sort") docCmd.Flags().StringVarP(&additionalDataPath, "add", "a", "", "additional schema data path") - docCmd.Flags().StringVarP(&outputFormat, "output", "o", "md", "output format") } diff --git a/cmd/root.go b/cmd/root.go index 03468beee..e86e26b90 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -36,9 +36,6 @@ var sort bool // additionalDataPath is a additional data path var additionalDataPath string -// outputFormat is output format -var outputFormat string - // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "tbls", diff --git a/output/dot/templates.go b/output/dot/templates.go index 002b105d4..d894c7427 100644 --- a/output/dot/templates.go +++ b/output/dot/templates.go @@ -11,19 +11,19 @@ var _Assets5bd148e6149bb9adcdddfcf8cc46d6e3047dbe26 = "digraph {{ .Table.Name }} // Assets returns go-assets FileSystem var Assets = assets.NewFileSystem(map[string][]string{"/": []string{"schema.dot.tmpl", "table.dot.tmpl"}}, map[string]*assets.File{ - "/": &assets.File{ + "/table.dot.tmpl": &assets.File{ + Path: "/table.dot.tmpl", + FileMode: 0x1a4, + Mtime: time.Unix(1527595732, 1527595732000000000), + Data: []byte(_Assets5bd148e6149bb9adcdddfcf8cc46d6e3047dbe26), + }, "/": &assets.File{ Path: "/", FileMode: 0x800001ed, - Mtime: time.Unix(1527518947, 1527518947000000000), + Mtime: time.Unix(1527595732, 1527595732000000000), Data: nil, }, "/schema.dot.tmpl": &assets.File{ Path: "/schema.dot.tmpl", FileMode: 0x1a4, Mtime: time.Unix(1527512634, 1527512634000000000), Data: []byte(_Assets21532ae17ad95976ac467eeaeab81f2bb1d537e4), - }, "/table.dot.tmpl": &assets.File{ - Path: "/table.dot.tmpl", - FileMode: 0x1a4, - Mtime: time.Unix(1527518947, 1527518947000000000), - Data: []byte(_Assets5bd148e6149bb9adcdddfcf8cc46d6e3047dbe26), }}, "") diff --git a/output/md/md.go b/output/md/md.go index 60d442180..46b167ffb 100644 --- a/output/md/md.go +++ b/output/md/md.go @@ -34,8 +34,13 @@ func Output(s *schema.Schema, path string, force bool) error { if err != nil { return err } + er := false + if _, err := os.Lstat(filepath.Join(fullPath, "schema.png")); err == nil { + er = true + } err = tmpl.Execute(file, map[string]interface{}{ "Schema": s, + "er": er, }) if err != nil { return err @@ -55,8 +60,13 @@ func Output(s *schema.Schema, path string, force bool) error { if err != nil { return err } + er := false + if _, err := os.Lstat(filepath.Join(fullPath, fmt.Sprintf("%s.png", t.Name))); err == nil { + er = true + } err = tmpl.Execute(file, map[string]interface{}{ "Table": t, + "er": er, }) if err != nil { return err @@ -84,8 +94,16 @@ func Diff(s *schema.Schema, path string) error { f, _ := Assets.Open(filepath.Join("/", "index.md.tmpl")) bs, _ := ioutil.ReadAll(f) tmpl, err := template.New("index").Parse(string(bs)) + if err != nil { + return err + } + er := false + if _, err := os.Lstat(filepath.Join(fullPath, "schema.png")); err == nil { + er = true + } err = tmpl.Execute(a, map[string]interface{}{ "Schema": s, + "er": er, }) if err != nil { return err @@ -111,8 +129,16 @@ func Diff(s *schema.Schema, path string) error { f, _ := Assets.Open(filepath.Join("/", "table.md.tmpl")) bs, _ := ioutil.ReadAll(f) tmpl, err := template.New(t.Name).Parse(string(bs)) + if err != nil { + return err + } + er := false + if _, err := os.Lstat(filepath.Join(fullPath, fmt.Sprintf("%s.png", t.Name))); err == nil { + er = true + } err = tmpl.Execute(a, map[string]interface{}{ "Table": t, + "er": er, }) if err != nil { return err diff --git a/output/md/templates.go b/output/md/templates.go index 98142a51f..36d59bf10 100644 --- a/output/md/templates.go +++ b/output/md/templates.go @@ -6,24 +6,24 @@ import ( "github.com/jessevdk/go-assets" ) -var _Assetsac44302fb6150a621aa9d04a0350aac972bf7e18 = "# {{ .Table.Name }}\n\n## Description\n\n{{ .Table.Comment }}\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---\n\n> Generated by [tbls](https://github.com/k1LoW/tbls)" -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---\n\n> Generated by [tbls](https://github.com/k1LoW/tbls)" +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\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{ Path: "/", FileMode: 0x800001ed, - Mtime: time.Unix(1527296235, 1527296235000000000), + Mtime: time.Unix(1527597737, 1527597737000000000), Data: nil, }, "/index.md.tmpl": &assets.File{ Path: "/index.md.tmpl", FileMode: 0x1a4, - Mtime: time.Unix(1526904993, 1526904993000000000), + Mtime: time.Unix(1527597737, 1527597737000000000), Data: []byte(_Assets43889384df1c6f74d764c29d91b9d5637eb46061), }, "/table.md.tmpl": &assets.File{ Path: "/table.md.tmpl", FileMode: 0x1a4, - Mtime: time.Unix(1527296235, 1527296235000000000), + Mtime: time.Unix(1527597735, 1527597735000000000), Data: []byte(_Assetsac44302fb6150a621aa9d04a0350aac972bf7e18), }}, "") diff --git a/output/md/templates/index.md.tmpl b/output/md/templates/index.md.tmpl index 4b5caa024..b20c9cf74 100644 --- a/output/md/templates/index.md.tmpl +++ b/output/md/templates/index.md.tmpl @@ -8,6 +8,12 @@ | [{{ $t.Name }}]({{ $t.Name }}.md) | {{ len $t.Columns }} | {{ $t.Comment }} | {{ $t.Type }} | {{- end }} +{{ if .er -}} +## Relations + +![er](schema.png) +{{- end }} + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/output/md/templates/table.md.tmpl b/output/md/templates/table.md.tmpl index 12272199c..5235002de 100644 --- a/output/md/templates/table.md.tmpl +++ b/output/md/templates/table.md.tmpl @@ -28,6 +28,12 @@ | {{ $idx.Name }} | {{ $idx.Def }} | {{- end }} +{{ if .er -}} +## Relations + +![er]({{ .Table.Name }}.png) +{{- end }} + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql/CamelizeTable.md b/sample/mysql/CamelizeTable.md index f396fe509..f59b41a33 100644 --- a/sample/mysql/CamelizeTable.md +++ b/sample/mysql/CamelizeTable.md @@ -23,6 +23,10 @@ | ---- | --- | | PRIMARY | PRIMARY KEY (id) USING BTREE | +## Relations + +![er](CamelizeTable.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql/CamelizeTable.png b/sample/mysql/CamelizeTable.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql/CamelizeTable.png differ diff --git a/sample/mysql/README.md b/sample/mysql/README.md index 4d3ff1dff..51a2ff1f3 100644 --- a/sample/mysql/README.md +++ b/sample/mysql/README.md @@ -12,6 +12,10 @@ | [posts](posts.md) | 7 | Posts table | BASE TABLE | | [users](users.md) | 6 | Users table | BASE TABLE | +## Relations + +![er](schema.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql/comment_stars.md b/sample/mysql/comment_stars.md index f7cfc6248..eda5010e4 100644 --- a/sample/mysql/comment_stars.md +++ b/sample/mysql/comment_stars.md @@ -33,6 +33,10 @@ | PRIMARY | PRIMARY KEY (id) USING BTREE | | user_id | UNIQUE KEY user_id (user_id, comment_post_id, comment_user_id) USING BTREE | +## Relations + +![er](comment_stars.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql/comment_stars.png b/sample/mysql/comment_stars.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql/comment_stars.png differ diff --git a/sample/mysql/comments.md b/sample/mysql/comments.md index b6d58c6cb..32195abac 100644 --- a/sample/mysql/comments.md +++ b/sample/mysql/comments.md @@ -33,6 +33,10 @@ | PRIMARY | PRIMARY KEY (id) USING BTREE | | post_id | UNIQUE KEY post_id (post_id, user_id) USING BTREE | +## Relations + +![er](comments.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql/comments.png b/sample/mysql/comments.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql/comments.png differ diff --git a/sample/mysql/logs.md b/sample/mysql/logs.md index 46ddf3d24..8d6412960 100644 --- a/sample/mysql/logs.md +++ b/sample/mysql/logs.md @@ -28,6 +28,10 @@ | ---- | --- | | PRIMARY | PRIMARY KEY (id) USING BTREE | +## Relations + +![er](logs.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql/logs.png b/sample/mysql/logs.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql/logs.png differ diff --git a/sample/mysql/post_comments.md b/sample/mysql/post_comments.md index 14665fe0c..022c0f075 100644 --- a/sample/mysql/post_comments.md +++ b/sample/mysql/post_comments.md @@ -26,6 +26,10 @@ VIEW | Name | Def | | ---- | --- | +## Relations + +![er](post_comments.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql/post_comments.png b/sample/mysql/post_comments.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql/post_comments.png differ diff --git a/sample/mysql/posts.md b/sample/mysql/posts.md index d2b8827d4..337619c87 100644 --- a/sample/mysql/posts.md +++ b/sample/mysql/posts.md @@ -32,6 +32,10 @@ Posts table | PRIMARY | PRIMARY KEY (id) USING BTREE | | user_id | UNIQUE KEY user_id (user_id, title) USING BTREE | +## Relations + +![er](posts.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql/posts.png b/sample/mysql/posts.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql/posts.png differ diff --git a/sample/mysql/schema.png b/sample/mysql/schema.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql/schema.png differ diff --git a/sample/mysql/users.md b/sample/mysql/users.md index a39331647..b5c8a6f83 100644 --- a/sample/mysql/users.md +++ b/sample/mysql/users.md @@ -31,6 +31,10 @@ Users table | email | UNIQUE KEY email (email) USING BTREE | | username | UNIQUE KEY username (username) USING BTREE | +## Relations + +![er](users.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql/users.png b/sample/mysql/users.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql/users.png differ diff --git a/sample/mysql8/CamelizeTable.md b/sample/mysql8/CamelizeTable.md index f396fe509..f59b41a33 100644 --- a/sample/mysql8/CamelizeTable.md +++ b/sample/mysql8/CamelizeTable.md @@ -23,6 +23,10 @@ | ---- | --- | | PRIMARY | PRIMARY KEY (id) USING BTREE | +## Relations + +![er](CamelizeTable.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql8/CamelizeTable.png b/sample/mysql8/CamelizeTable.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql8/CamelizeTable.png differ diff --git a/sample/mysql8/README.md b/sample/mysql8/README.md index 4d3ff1dff..51a2ff1f3 100644 --- a/sample/mysql8/README.md +++ b/sample/mysql8/README.md @@ -12,6 +12,10 @@ | [posts](posts.md) | 7 | Posts table | BASE TABLE | | [users](users.md) | 6 | Users table | BASE TABLE | +## Relations + +![er](schema.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql8/comment_stars.md b/sample/mysql8/comment_stars.md index 25fa684b2..7b329795a 100644 --- a/sample/mysql8/comment_stars.md +++ b/sample/mysql8/comment_stars.md @@ -33,6 +33,10 @@ | PRIMARY | PRIMARY KEY (id) USING BTREE | | user_id | UNIQUE KEY user_id (user_id, comment_post_id, comment_user_id) USING BTREE | +## Relations + +![er](comment_stars.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql8/comment_stars.png b/sample/mysql8/comment_stars.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql8/comment_stars.png differ diff --git a/sample/mysql8/comments.md b/sample/mysql8/comments.md index b6d58c6cb..32195abac 100644 --- a/sample/mysql8/comments.md +++ b/sample/mysql8/comments.md @@ -33,6 +33,10 @@ | PRIMARY | PRIMARY KEY (id) USING BTREE | | post_id | UNIQUE KEY post_id (post_id, user_id) USING BTREE | +## Relations + +![er](comments.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql8/comments.png b/sample/mysql8/comments.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql8/comments.png differ diff --git a/sample/mysql8/logs.md b/sample/mysql8/logs.md index 46ddf3d24..8d6412960 100644 --- a/sample/mysql8/logs.md +++ b/sample/mysql8/logs.md @@ -28,6 +28,10 @@ | ---- | --- | | PRIMARY | PRIMARY KEY (id) USING BTREE | +## Relations + +![er](logs.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql8/logs.png b/sample/mysql8/logs.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql8/logs.png differ diff --git a/sample/mysql8/post_comments.md b/sample/mysql8/post_comments.md index 14665fe0c..022c0f075 100644 --- a/sample/mysql8/post_comments.md +++ b/sample/mysql8/post_comments.md @@ -26,6 +26,10 @@ VIEW | Name | Def | | ---- | --- | +## Relations + +![er](post_comments.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql8/post_comments.png b/sample/mysql8/post_comments.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql8/post_comments.png differ diff --git a/sample/mysql8/posts.md b/sample/mysql8/posts.md index d2b8827d4..337619c87 100644 --- a/sample/mysql8/posts.md +++ b/sample/mysql8/posts.md @@ -32,6 +32,10 @@ Posts table | PRIMARY | PRIMARY KEY (id) USING BTREE | | user_id | UNIQUE KEY user_id (user_id, title) USING BTREE | +## Relations + +![er](posts.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql8/posts.png b/sample/mysql8/posts.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql8/posts.png differ diff --git a/sample/mysql8/schema.png b/sample/mysql8/schema.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql8/schema.png differ diff --git a/sample/mysql8/users.md b/sample/mysql8/users.md index 5326038a3..e68358aee 100644 --- a/sample/mysql8/users.md +++ b/sample/mysql8/users.md @@ -31,6 +31,10 @@ Users table | email | UNIQUE KEY email (email) USING BTREE | | username | UNIQUE KEY username (username) USING BTREE | +## Relations + +![er](users.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/mysql8/users.png b/sample/mysql8/users.png new file mode 100644 index 000000000..157bdc612 Binary files /dev/null and b/sample/mysql8/users.png differ diff --git a/sample/postgres/CamelizeTable.md b/sample/postgres/CamelizeTable.md index bade2a7d9..5bc5b0d8c 100644 --- a/sample/postgres/CamelizeTable.md +++ b/sample/postgres/CamelizeTable.md @@ -21,6 +21,10 @@ | Name | Def | | ---- | --- | +## Relations + +![er](CamelizeTable.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/postgres/CamelizeTable.png b/sample/postgres/CamelizeTable.png new file mode 100644 index 000000000..1424faab9 Binary files /dev/null and b/sample/postgres/CamelizeTable.png differ diff --git a/sample/postgres/README.md b/sample/postgres/README.md index 188b32b1c..eabc2155e 100644 --- a/sample/postgres/README.md +++ b/sample/postgres/README.md @@ -12,6 +12,10 @@ | [post_comments](post_comments.md) | 7 | | VIEW | | [CamelizeTable](CamelizeTable.md) | 2 | | BASE TABLE | +## Relations + +![er](schema.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/postgres/comment_stars.md b/sample/postgres/comment_stars.md index 89c3e84a8..3e69aa25f 100644 --- a/sample/postgres/comment_stars.md +++ b/sample/postgres/comment_stars.md @@ -29,6 +29,10 @@ | ---- | --- | | comment_stars_user_id_comment_post_id_comment_user_id_key | CREATE UNIQUE INDEX comment_stars_user_id_comment_post_id_comment_user_id_key ON public.comment_stars USING btree (user_id, comment_post_id, comment_user_id) | +## Relations + +![er](comment_stars.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/postgres/comment_stars.png b/sample/postgres/comment_stars.png new file mode 100644 index 000000000..1424faab9 Binary files /dev/null and b/sample/postgres/comment_stars.png differ diff --git a/sample/postgres/comments.md b/sample/postgres/comments.md index 6a063ee34..2838a5204 100755 --- a/sample/postgres/comments.md +++ b/sample/postgres/comments.md @@ -32,6 +32,10 @@ | comments_post_id_user_id_key | CREATE UNIQUE INDEX comments_post_id_user_id_key ON public.comments USING btree (post_id, user_id) | | comments_post_id_user_id_idx | CREATE INDEX comments_post_id_user_id_idx ON public.comments USING btree (post_id, user_id) | +## Relations + +![er](comments.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/postgres/comments.png b/sample/postgres/comments.png new file mode 100644 index 000000000..1424faab9 Binary files /dev/null and b/sample/postgres/comments.png differ diff --git a/sample/postgres/logs.md b/sample/postgres/logs.md index a18ed0e42..282817221 100644 --- a/sample/postgres/logs.md +++ b/sample/postgres/logs.md @@ -26,6 +26,10 @@ | Name | Def | | ---- | --- | +## Relations + +![er](logs.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/postgres/logs.png b/sample/postgres/logs.png new file mode 100644 index 000000000..1424faab9 Binary files /dev/null and b/sample/postgres/logs.png differ diff --git a/sample/postgres/post_comments.md b/sample/postgres/post_comments.md index e19e7acae..851f109fa 100644 --- a/sample/postgres/post_comments.md +++ b/sample/postgres/post_comments.md @@ -26,6 +26,10 @@ | Name | Def | | ---- | --- | +## Relations + +![er](post_comments.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/postgres/post_comments.png b/sample/postgres/post_comments.png new file mode 100644 index 000000000..1424faab9 Binary files /dev/null and b/sample/postgres/post_comments.png differ diff --git a/sample/postgres/posts.md b/sample/postgres/posts.md index 77230d7a6..8b776fcc6 100755 --- a/sample/postgres/posts.md +++ b/sample/postgres/posts.md @@ -33,6 +33,10 @@ Posts table | posts_user_id_title_key | CREATE UNIQUE INDEX posts_user_id_title_key ON public.posts USING btree (user_id, title) | | posts_user_id_idx | CREATE INDEX posts_user_id_idx ON public.posts USING btree (user_id) | +## Relations + +![er](posts.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/postgres/posts.png b/sample/postgres/posts.png new file mode 100644 index 000000000..1424faab9 Binary files /dev/null and b/sample/postgres/posts.png differ diff --git a/sample/postgres/schema.png b/sample/postgres/schema.png new file mode 100644 index 000000000..1424faab9 Binary files /dev/null and b/sample/postgres/schema.png differ diff --git a/sample/postgres/users.md b/sample/postgres/users.md index f12116738..63670ab3e 100755 --- a/sample/postgres/users.md +++ b/sample/postgres/users.md @@ -32,6 +32,10 @@ Users table | users_username_key | CREATE UNIQUE INDEX users_username_key ON public.users USING btree (username) | | users_email_key | CREATE UNIQUE INDEX users_email_key ON public.users USING btree (email) | +## Relations + +![er](users.png) + --- > Generated by [tbls](https://github.com/k1LoW/tbls) \ No newline at end of file diff --git a/sample/postgres/users.png b/sample/postgres/users.png new file mode 100644 index 000000000..1424faab9 Binary files /dev/null and b/sample/postgres/users.png differ