#!/bin/sh

echo "WARNING: DO NOT PROCEED UNLESS YOU KNOW YOU ARE LOSING DATA!"

echo -n "Dump current DB [yN]?"
read YORN
if [ $YORN != 'y' -a $YORN != 'Y' ]; then
	exit
fi
echo "OK..."
mysqladmin -u root -p drop sms

echo -n "Create DB [yN]?"
read YORN
if [ $YORN != 'y' -a $YORN != 'Y' ]; then
	exit
fi
echo "OK..."
mysqladmin -u root -p create sms
echo -n "Reload DB [yN]?"
read YORN
if [ $YORN != 'y' -a $YORN != 'Y' ]; then
	exit;
fi
echo "OK..."
mysqladmin -u root -p reload

echo -n "Create tables and load data [yN]?";
read YORN
if [ $YORN != 'y' -a $YORN != 'Y' ]; then
	exit;
fi

mysql -u root -p sms <<__EOF__
# The Person table has each individuals preferences


CREATE TABLE inbox (
  id int(10) unsigned NOT NULL auto_increment,
  number varchar(20) NOT NULL default '',
  smsdate datetime NOT NULL default '0000-00-00 00:00:00',
  insertdate timestamp(14) NOT NULL,
  text varchar(160) default NULL,
  processed tinyint(4) NOT NULL default '0',
  been_displayed tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (id)
) TYPE=MyISAM;


CREATE TABLE outbox (
  id int(10) unsigned NOT NULL auto_increment,
  number varchar(20) NOT NULL default '',
  processed_date timestamp(14) NOT NULL,
  insertdate timestamp(14) NOT NULL,
  text varchar(160) default NULL,
  processed tinyint(4) NOT NULL default '0',
  error tinyint(4) NOT NULL default '-1',
  PRIMARY KEY  (id)
) TYPE=MyISAM;

# Permissions
GRANT select,insert,update on inbox to 'trs80'@localhost;
GRANT select,insert,update on inbox to 'dagobah'@localhost;

__EOF__
