Permalink
Browse files

Make the setup and upgrade script work

The script wasn't looking at the content of the file to see on which patches
this patch depended.

The files are now also named like the patch they register, so we can actually
find the patch we're trying to apply.

This fixes #BB-21
  • Loading branch information...
1 parent 90d7b86 commit 43c0bdbb9c22454db9024ac30be7258170b27cb7 @kroeckx kroeckx committed Jun 2, 2012
Showing with 10 additions and 10 deletions.
  1. +5 −5 setup.sh
  2. +5 −5 upgrade.sh
View
@@ -12,19 +12,19 @@ echo `date` : Upgrading database schema
find sql -type f -name '*.sql' | \
sed 's/^[^(]*(//' | while read LINE
do
- export PATCH_NAME="$( echo "$LINE" | cut -d\' -f2 )"
- echo "$LINE" | sed "s/^[^']*'[^']\\+'[[:space:]]*,[[:space:]]*//" | \
+ export PATCH_NAME="$( cat "$LINE" |grep register_patch | cut -d\' -f2 )"
+ cat "$LINE" | grep register_patch | sed "s/^[^']*'[^']\\+'[[:space:]]*,[[:space:]]*//" | \
perl -ne '
my @w;
if ( s/^ARRAY\s*\[// ) {
s/\].*//;
@w = /\047([^\047]+)\047/g;
}
push @w, $ENV{"PATCH_NAME"} if ( 0 == @w ) || ( 0 == ( @w % 2 ) );
- printf "%s %s\n", $ENV{"PATCH_NAME"}, $_ for @w;
+ printf "%s %s\n", $_, $ENV{"PATCH_NAME"} for @w;
'
- done | tsort | tac | while read LINE
+ done | tsort | while read LINE
do
echo `date` : Applyling $LINE
- psql -U bookbrainz bookbrainz < $LINE
+ psql -U bookbrainz bookbrainz < sql/$LINE.sql
done
View
@@ -7,21 +7,21 @@ echo `date` : Upgrading database schema
git diff --name-only $CURRENT...HEAD -- sql | \
sed 's/^[^(]*(//' | while read LINE
do
- export PATCH_NAME="$( echo "$LINE" | cut -d\' -f2 )"
- echo "$LINE" | sed "s/^[^']*'[^']\\+'[[:space:]]*,[[:space:]]*//" | \
+ export PATCH_NAME="$( cat "$LINE" |grep register_patch | cut -d\' -f2 )"
+ cat "$LINE" | grep register_patch | sed "s/^[^']*'[^']\\+'[[:space:]]*,[[:space:]]*//" | \
perl -ne '
my @w;
if ( s/^ARRAY\s*\[// ) {
s/\].*//;
@w = /\047([^\047]+)\047/g;
}
push @w, $ENV{"PATCH_NAME"} if ( 0 == @w ) || ( 0 == ( @w % 2 ) );
- printf "%s %s\n", $ENV{"PATCH_NAME"}, $_ for @w;
+ printf "%s %s\n", $_, $ENV{"PATCH_NAME"} for @w;
'
- done | tsort | tac | while read LINE
+ done | tsort | while read LINE
do
echo `date` : Applyling $LINE
- psql -U bookbrainz bookbrainz < $LINE
+ psql -U bookbrainz bookbrainz < sql/$LINE.sql
done
echo `date` : Done

0 comments on commit 43c0bdb

Please sign in to comment.