Permalink
Browse files

Adding a very basic setup script to get going

  • Loading branch information...
1 parent f9e6e89 commit b800d5cd0af7a7647a7f668dac1ed122bbc56761 Oliver Charles committed Jul 8, 2011
Showing with 51 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +11 −0 README
  3. +1 −0 Versioning
  4. +9 −0 setup.sh
  5. +27 −0 upgrade.sh
View
@@ -0,0 +1,3 @@
+[submodule "Versioning"]
+ path = Versioning
+ url = https://github.com/depesz/Versioning.git
View
11 README
@@ -1 +1,12 @@
BookBrainz - unique identifiers for books and texts
+
+Assuming you are running Ubuntu with PostgreSQL installed (basically
+assuming you can run the MusicBrainz server):
+
+ ./setup.sh
+
+Then:
+
+ ./upgrade.sh
+
+To run the latest code/schema
Submodule Versioning added at 9e2302
View
@@ -0,0 +1,9 @@
+echo `date` : Creating bookbrainz database and user
+sudo -u postgres createuser -S -D -R bookbrainz
+sudo -u postgres createdb -O bookbrainz bookbrainz
+sudo -u postgres createlang -U bookbrainz plpgsql bookbrainz
+
+echo `date` : Installing Versioning
+git submodule init
+git submodule update
+psql -U bookbrainz bookbrainz < ./Versioning/install.versioning.sql
View
@@ -0,0 +1,27 @@
+CURRENT=`git rev-parse HEAD`
+
+echo `date` : Upgrading code
+git pull -r --ff-only origin master
+
+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:]]*//" | \
+ 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;
+ '
+ done | tsort | tac | while read LINE
+ do
+ echo `date` : Applyling $LINE
+ psql -U bookbrainz bookbrainz < $LINE
+ done
+
+echo `date` : Done

0 comments on commit b800d5c

Please sign in to comment.