#!/bin/csh
#
# Master script for shadowing database metabase on KSUMMIT from YAKUZA master
#
# get last known dynamaps data, and shame on you if it isn't up to date
echo "get Dynamaps data as of right now "
#
/bin/rm -f Done
#
./getDyna2
# ls -l ../metabase/DynaMaps.dat
# /bin/cp -f ../metabase/DynaMaps.dat .
#
/bin/rm Update.out
# users and accounts are already set up, and there aren't any types, defs, or rules
# isql -Usa -PSecretPassword -SKTUNNEL < metabase.usr.sql >>&! Update.out
# isql -Usa -PSecretPassword -SKTUNNEL < metabase.act.sql >>&! Update.out
# isql -Usa -PSecretPassword -SKTUNNEL < metabase.typ.sql >>&! Update.out
# isql -Usa -PSecretPassword -SKTUNNEL < metabase.def.sql >>&! Update.out
# isql -Usa -PSecretPassword -SKTUNNEL < metabase.rul.sql >>&! Update.out
#
# here we go...
isql -Usa -PSecretPassword -SKTUNNEL < metabase.tbl.sql >>&! Update.out
#
/bin/rm -f Rel.csh
mv Reload.metabase.csh Rel.csh
# don't copy that monstrous glob of survey data
sed 's/YAKUZA/KSUMMIT/' Rel.csh | grep -v Survey > Reload.metabase.csh
#
/bin/rm -f BCP.out
source Reload.metabase.csh >& BCP.out
#
isql -Usa -PSecretPassword -SKSUMMIT < metabase.idx.sql >>&! Update.out
isql -Usa -PSecretPassword -SKSUMMIT < metabase.vuw.sql >>&! Update.out
isql -Usa -PSecretPassword -SKSUMMIT < metabase.pro.sql >>&! Update.out
# you don't need triggers. you're a passive copy, and they're likely to give syntax errs.
# hmm, but you DO need triggers for Dynamaps since inconfig inserts into that table
# in future we'll be doing inserts into table Mask but it's triggerless.
isql -Usa -PSecretPassword -SKSUMMIT < dynamaps.trg.sql >>&! Update.out
isql -Usa -PSecretPassword -SKSUMMIT < metabase.acl.sql >>&! Update.out
isql -Usa -PSecretPassword -SKSUMMIT < metabase.key.sql >>&! Update.out
#
# lastly, patch the dyna record ids
isql -Usa -PSecretPassword -SKSUMMIT < dynafix.sql >>&! Update.out
#
touch Done