#!/bin/csh -f

set tables = (magnetic_fields)
set database = user_geometry 
rm -rf tmp.txt

echo use $database\; > tmp.txt

foreach t ($tables)
  echo drop table $t\; >> tmp.txt
  echo create table user_geometry.magnetic_fields \(  name          VARCHAR\(40\) UNIQUE\)\; >> tmp.txt
  echo alter table magnetic_fields add column          type          VARCHAR\(150\)\; >> tmp.txt
  echo alter table magnetic_fields add column          magnitude     VARCHAR\(240\)\; >> tmp.txt
  echo alter table magnetic_fields add column          swim_method   VARCHAR\(40\)\; >> tmp.txt
  echo alter table magnetic_fields add column          description   VARCHAR\(100\)\; >> tmp.txt
  echo LOAD DATA LOCAL INFILE \'$t.txt\'  into TABLE magnetic_fields\; >> tmp.txt
end

mysql -h $GEMC_HOST -u $GEMC_USER < tmp.txt
sleep 4
rm -rf tmp.txt
