add res[et] command to sql/builder.sh script with del+ins commands integrated in...
[brisk.git] / sql / builder.sh
index 4acc242..2f0e60c 100755 (executable)
@@ -14,7 +14,9 @@ usage () {
     echo "       rebuild"
     echo "       psql"
     echo "       piped"
-    echo "       add <filesql>"
+    echo "       add <filesql> [<filesql2> [..]]"
+    echo "       del <filesql> [<filesql2> [..]]"
+    echo "       res <filesql> [<filesql2> [..]]"
     echo "       dump [dumpfile]"
     echo "       dumpall [dumpfile]"
     echo "       all"
@@ -100,7 +102,7 @@ test "$DBUSER" != "" && pg_args="$pg_args -U $DBUSER"
 test "$DBPORT" != "" && pg_args="$pg_args -p $DBPORT"
 test "$DBBASE" != "" && pg_args="$pg_args $DBBASE"
 
-MATCH_DROP='^drop|^alter table.* drop '
+MATCH_DROP='^drop|^alter table.* drop |^delete '
 
 case $CMD in
     "create")
@@ -145,7 +147,13 @@ case $CMD in
         fi
         ;;
     "add")
-        cat "$1" | sqlexe
+        ( echo "-- MESG: add start" ; cat "$@" | egrep -iv "$MATCH_DROP" ; echo "-- MESG: add end" ;   ) | sqlexe
+        ;;
+    "del")
+        ( echo "-- MESG: del start" ; cat "$@" | egrep -i  "$MATCH_DROP" | tac ; echo "-- MESG: del end" ;   ) | sqlexe
+        ;;
+    "res")
+        ( echo "-- MESG: res start" ; cat "$@" | egrep -i  "$MATCH_DROP" | tac ; cat "$@" | egrep -iv "$MATCH_DROP" ; echo "-- MESG: del end" ;   ) | sqlexe
         ;;
     "help"|"-h"|"--help")
         usage 0
@@ -155,4 +163,4 @@ case $CMD in
         ;;
 esac
 
-exit 0
\ No newline at end of file
+exit 0