]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/grab-db-comments.pl
lp1863252 toward geosort
[Evergreen.git] / Open-ILS / src / sql / Pg / grab-db-comments.pl
1 #!/usr/bin/perl
2
3 # Copyright (C) 2011 Equinox Software, Inc.
4 # Galen Charlton <gmc@esilibrary.com>
5 #
6 # Extract 'comment on' statements from Evergreen's SQL initialization
7 # scripts.  Useful for updating the comments after an upgrade.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18
19 use strict;
20 use warnings;
21
22 unless ($#ARGV == 0) {
23     print "usage: $0 sql_file_manifest\n";
24     print "output is a set of SQL statements to be run\n";
25     print "in an Evergreen database to update schema comments.\n";
26     exit(1);
27 }
28
29 open MANIFEST, '<', $ARGV[0];
30 while (<MANIFEST>) {
31     chomp;
32     my $file = $_;
33     $file =~ s/\s+$//;
34     $file =~ s/^\s+//;
35     next unless $file ne '' and $file !~ /^#/ and $file ne 'FTS_CONFIG_FILE';
36     open IN, '<', $file or next; # errors blithely ignored
37     my $contents = join('', <IN>);
38     print "$_\n\n" foreach $contents =~ /(comment on .*? is \$\$.*?\$\$;)/sig;
39     #my @comments =  $contents =~ /(comment on .*? is \$\$.*?\$\$;)/sig;
40     #foreach my $comment (@comments) {
41         #print $comment, "\n\n";
42     #}
43     close IN;
44 }
45 close MANIFEST;