From 9f7c1679771ba865e9741006ba158733299f5672 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Sat, 23 Aug 2014 19:39:09 -0700 Subject: [PATCH] add rules for dak schema --- debconf14/figures/Makefile | 9 +++++++ debconf14/figures/draw_dak_schema.pl | 38 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 debconf14/figures/draw_dak_schema.pl diff --git a/debconf14/figures/Makefile b/debconf14/figures/Makefile index 4a04919..0164c81 100644 --- a/debconf14/figures/Makefile +++ b/debconf14/figures/Makefile @@ -15,3 +15,12 @@ all: openlogo-crop.pdf bug_global_layout.pdf schema.png: draw_schema.pl perl -I ~/projects/debbugs/debbugs $< $@ + +# dak_schema.png: draw_dak_schema.pl +# cat ~/projects/debian/dak/setup/current_schema.sql| \ +# grep -v 'CREATE SCHEMA'|grep -v 'SET'|\ +# perl $< /dev/stdin $@ + +dak_schema.png: draw_dak_schema.pl + wget -O dak_schema.sql "http://git.donarmstrong.com/?p=dak.git;a=blob_plain;f=setup/schema_68.sql;h=afe94e9b474bc85334c12c50f33017c55ed4e373;hb=HEAD" + perl $< dak_schema.sql $@ diff --git a/debconf14/figures/draw_dak_schema.pl b/debconf14/figures/draw_dak_schema.pl new file mode 100644 index 0000000..1621ef2 --- /dev/null +++ b/debconf14/figures/draw_dak_schema.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +use SQL::Translator; +use IO::File; + +my $fh = IO::File->new($ARGV[0]); + +my $keep = 0; +my $file = ''; +while (<$fh>) { + if (/CREATE\s*TABLE/i) { + $keep = 1; + $file .= $_; + } + elsif (/^\s*\);\s*$/) { + $file .= $_; + $keep = 0; + } elsif ($keep) { + $file .= $_; + } elsif (/CREATE\s*(UNIQUE\s*)?INDEX/i) { + $file .= $_; + } +} + +my $trans = SQL::Translator->new( + parser => 'SQL::Translator::Parser::PostgreSQL', + producer => 'Diagram', + producer_args => { + out_file => $ARGV[1], + show_constraints => 1, + show_datatypes => 1, + show_sizes => 1, + show_fk_only => 0, + } ); +$trans->translate(\$file); -- 2.39.2