parent
b5c0f1f0a8
commit
11aedd59de
3 changed files with 45 additions and 30 deletions
@ -1,25 +1,41 @@ |
||||
#! /bin/sed -f |
||||
1idigraph schema { |
||||
1i\ |
||||
/** @page database Database Schema\ |
||||
\ |
||||
@dot\ |
||||
digraph schema { |
||||
|
||||
# remove newlines |
||||
:a;N;$!ba;s/\n/ /g |
||||
# reduce spaces |
||||
s, \+, ,g |
||||
|
||||
s| *CREATE TABLE[^("'`]*[`"']\?\([a-z]\+\)[`"']\? *|\n \1\n [shape=none, margin=0, label=<\n <table>\n <tr><td colspan="3"><b>\1</b></td></tr>\n|ig |
||||
s| *CREATE *TABLE *\(if *not *exists\)\? *`\?\([a-z]\+\)`\? *|\n \2\n [shape=none, margin=0, label=<\n <table bgcolor="#dddddd">\n <tr><td bgcolor="#ddddff" colspan="4"><b>\2</b></td></tr>\n|ig |
||||
|
||||
s/varchar *( *\([0-9]\+\) *)/varchar[\1]/ig |
||||
|
||||
s/ *PRIMARY KEY *( *[`"']\?\([a-z]\+\)[`"']\? *) *[,)]//ig |
||||
s/ *PRIMARY KEY *( *`\?\([a-z]\+\)`\? *) *[,)]//ig |
||||
|
||||
:b;s/\([a-z]\+\)\([^;]*\)FOREIGN KEY *( *[`"']\?\([a-z]\+\)[`"']\? *) *REFERENCES *[`"']\?\([a-z]\+\)[`"'] *( *[`"']\?\([a-z]\+\)[`"']\? *) *\([^,)]*\)[,)]\(.*\)/\1\2\7\n \1:\3 -> \4:\5/ig;tb |
||||
:b;s/\([a-z]\+\)\([^;]*\)FOREIGN KEY *( *`\?\([a-z]\+\)`\? *) *REFERENCES *`\?\([a-z]\+\)`\? *( *`\?\([a-z]\+\)`\? *) *\([^,)]*\)[,)]\(.*\)/\1\2\7\n \1:\3 -> \4:\5/ig;tb |
||||
|
||||
s| *COMMENT *= *[`"']\?\([^`"']*\)[`"']\?| <tr><td colspan="3">\1</td></tr>|ig |
||||
:c;s|\n[(,] *`\?\([a-z]\+\)`\? *\([^ ]\+\)*\([^,)]*\) *COMMENT *[`"']\([^`"']*\)[`"'] *[,)]|\n <tr><td align="left" port="\1"><b>\1</b></td><td align="left">\2</td><td align="left">\3</td><td align="left">\4</td></tr>\n,|ig;tc |
||||
|
||||
s| *[`"']\([a-z]\+\)[`"'] *\([^,)]*\) *COMMENT *[`"']\([^`"']*\)[`"'] *[,)]| <tr><td port="\1">\1</td><td>\2</td><td>\3</td></tr>\n|ig |
||||
s| \+</td>|</td>|g |
||||
s|<td> \+|<td>|g |
||||
s|\(<td[^>]*>[^<]\{30,40\}\) \+\([^<]\{20,\}</td>\)|\1<br/>\2|g |
||||
:d;s|\(<br/>[^<]\{30,40\}\) \+\([^<]\{20,\}</td>\)|\1<br/>\2|g;td |
||||
|
||||
s/ *ENGINE *= *\w* *//ig |
||||
s/ *DEFAULT *CHARSET *= *\w* *//ig |
||||
s/ *CHARACTER *SET *=\? *\w* *//ig |
||||
s| *COMMENT *= *["']\?\([^"']*\)["']\?|\n <tr><td bgcolor="#ddddff" colspan="4">\1</td></tr>|ig |
||||
|
||||
s| \+</td>|</td>|g |
||||
s|<td> \+|<td>|g |
||||
s|\(<td[^>]*>[^<]\{60,80\}\) \+\([^<]\{30,\}</td>\)|\1<br/>\2|g |
||||
:e;s|\(<br/>[^<]\{60,80\}\) \+\([^<]\{30,\}</td>\)|\1<br/>\2|g;te |
||||
|
||||
s/\n,[^\n]*/\n/g |
||||
s|;|\n </table>\n >];\n|ig |
||||
s/(//ig |
||||
|
||||
$a} |
||||
$a\ |
||||
}\ |
||||
@enddot\ |
||||
*/ |
||||
|
Loading…
Reference in new issue