From 015a697755ee7159c210b123e2060cef9d0b3fbc Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Tue, 17 May 2011 13:50:44 -0400 Subject: [PATCH] Improvements to make-db-patch.pl Grab all changes to base sql files into the upgrade script Based on HEAD (uncommitted changes) or --from=refspec Signed-off-by: Thomas Berezansky Signed-off-by: Galen Charlton --- Open-ILS/src/sql/Pg/make-db-patch.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/sql/Pg/make-db-patch.pl b/Open-ILS/src/sql/Pg/make-db-patch.pl index ffb1b01111..30993b89ed 100755 --- a/Open-ILS/src/sql/Pg/make-db-patch.pl +++ b/Open-ILS/src/sql/Pg/make-db-patch.pl @@ -22,6 +22,7 @@ use Getopt::Long; my $db_patch_num; my $patch_name; +my $patch_from; my @deprecates; my @supersedes; @@ -29,6 +30,7 @@ exit_usage() if $#ARGV == -1; GetOptions( 'num=i' => \$db_patch_num, 'name=s' => \$patch_name, + 'from=s' => \$patch_from, 'deprecates=i' => \@deprecates, 'supersedes=i' => \@supersedes, ) or exit_usage(); @@ -36,6 +38,8 @@ GetOptions( exit_usage('--num required') unless defined $db_patch_num; exit_usage('--name required') unless defined $patch_name; +$patch_from = 'HEAD' unless defined $patch_from; + # pad to four digits $db_patch_num = sprintf('%-04.4d', $db_patch_num); $_ = sprintf('%-04.4d', $_) foreach @deprecates; @@ -92,12 +96,16 @@ if (@deprecates or @supersedes) { ");\n"; } +my $patch_init_contents; +$patch_init_contents = `git diff $patch_from -- ./[0-9][0-9][0-9].*.sql | sed -e '/^[^+-]/d' -e '/^\\(--- a\\|+++ b\\)/d' -e 's/^+//'` if ($patch_from ne ''); + print OUT <<_FOOTER_; -- check whether patch can be applied SELECT evergreen.update_deps_block_check('$db_patch_num', :eg_version); --- FIXME: add SQL statements to perform the upgrade +-- FIXME: add/check SQL statements to perform the upgrade +$patch_init_contents COMMIT; _FOOTER_ @@ -117,6 +125,7 @@ Make template for a DB patch SQL file. --name descriptive part of patch filename --deprecates patch(es) deprecated by this update --supersedes patch(es) superseded by this update + --from git refspec to compare against _HELP_ exit 0; } -- 2.43.2