diff options
author | David Wührer <def@gmx.at> | 2024-05-18 21:04:34 +0200 |
---|---|---|
committer | David Wührer <def@gmx.at> | 2024-05-18 21:04:34 +0200 |
commit | 77cfffee6177fb0421fa0fce15d6a1875bde4816 (patch) | |
tree | 251428cdd482ea50cfb019dbd3c3bafd79d2fd14 /map-db | |
parent | 75b23ce1ff0daab363725a2a5755ea80bbeaa68e (diff) |
manuals, sum-down, radix
Diffstat (limited to 'map-db')
-rwxr-xr-x | map-db | 60 |
1 files changed, 0 insertions, 60 deletions
@@ -1,60 +0,0 @@ -#!/bin/bash - -query(){ -# psql-gridware -A -F$'\t' -t -P pager=off -c "$@" -# psql-gridware -A -F$'\t' -P pager=off -P title=off -c "$@" - psql-gridware -A -F$'\t' -P pager=off -c "$@" -} - -exec {in}<&0 - -pforkey(){ - echo '</TABLE>>]' - open_table=0 - data=forkey -} -forkey(){ - # ${constraint name} FOREIGN KEY (${Column}) REFERENCES ${table}(${Column}) - read -ra line <<<"$Column" - this_column=${line[3]%)} - this_column=${this_column#(} - other_table=${line[5]%%(*} - other_column=${line[5]##*\(} - other_column=${other_column%)} - printf '%s:%s_out -> %s:%s_in\n' "$table" "$this_column" "$other_table" "$other_column" -} - -record(){ - if [[ $Nullable = 'not null' ]] - then - echo "<TR><TD PORT=\"${Column}_in\"><U>$Column</U></TD><TD PORT=\"${Column}_out\">$Type</TD></TR>" - else - echo "<TR><TD PORT=\"${Column}_in\">$Column</TD><TD PORT=\"${Column}_out\">$Type</TD></TR>" - fi -} - -echo 'strict digraph db {' -echo 'node[shape=plain]' -query '\d' -t | cut -f 2,3 | grep table\$ | cut -f1 | while read -r table -do - printf '\e[1m%s\e[0m\n' "$table" >&2 - data=record - open_table=1 - echo - echo "$table [label=<<TABLE BORDER=\"0\"><TR><TD COLSPAN=\"2\">\\N</TD></TR>" - echo '<HR/>' - while IFS=$'\t' read -r Column Type Collation Nullable Default - do - case $Column in - Foreign-key\ constraints:) - echo >&2 'foreign keys' - data=pforkey - ;; *:) - echo >&2 '… skipping '"$Column" - data=: - esac - $data - done < <(query '\d '"$table" <&${in} | tail -n+3 | tr -d $'\r') - [[ $open_table = 1 ]] && echo '</TABLE>>]' -done -echo '}' |