-- MySQL dump 10.11
--
-- Host: ippdb01    Database: ipptopsps
-- ------------------------------------------------------
-- Server version	5.0.77-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `batch`
--

DROP TABLE IF EXISTS `batch`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `batch` (
  `batch_id` bigint(20) unsigned NOT NULL auto_increment,
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `batch_type` varchar(10) NOT NULL,
  `survey` varchar(10) default NULL,
  `dvo_db` varchar(100) default NULL,
  `datastore_product` varchar(100) default NULL,
  `min_obj_id` bigint(20) default NULL,
  `max_obj_id` bigint(20) default NULL,
  `processed` tinyint(4) default '0',
  `loaded_to_datastore` tinyint(4) default '0',
  `loaded_to_ODM` tinyint(4) default '0',
  `merge_worthy` tinyint(4) default '0',
  `merged` tinyint(4) default '0',
  `deleted_local` tinyint(4) default '0',
  `deleted_datastore` tinyint(4) default '0',
  `deleted_dxlayer` tinyint(4) default '0',
  `block_delete_local` tinyint(4) default '0',
  `block_delete_datastore` tinyint(4) default '0',
  `block_delete_dxlayer` tinyint(4) default '0',
  `stage_id` bigint(20) default NULL,
  `total_detections` bigint(20) default NULL,
  `skychunk` varchar(400) default NULL,
  `datastore_file` varchar(400) default NULL,
  `comment` varchar(400) default NULL,
  `purged` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`batch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;


--
-- Table structure for table `clients`
--

DROP TABLE IF EXISTS `clients`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `clients` (
  `started` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `type` varchar(50) default NULL,
  `pid` bigint(20) unsigned NOT NULL,
  `host` varchar(20) NOT NULL,
  `skychunk` varchar(30) default NULL,
  `paused` tinyint(1) default '0',
  `killed` tinyint(1) default '0',
  `timestamp` timestamp NOT NULL default '0000-00-00 00:00:00',
  `id` bigint(20) unsigned NOT NULL auto_increment,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `unique_key` (`host`,`pid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `skychunk`
--

DROP TABLE IF EXISTS `skychunk`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `skychunk` (
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `name` varchar(30) NOT NULL,
  `datastore_product` varchar(30) default NULL,
  `datastore_type` varchar(30) default 'IPP_PSPS',
  `datastore_publish` tinyint(1) default '0',
  `dvo_label` varchar(100) default NULL,
  `dvo_location` varchar(1000) default NULL,
  `min_ra` double default '0',
  `max_ra` double default '360',
  `min_dec` double default '-30',
  `max_dec` double default '90',
  `box_size` double default '4',
  `base_path` varchar(1000) default '/data/ipp005.0/ipptopsps/',
  `data_release` smallint(6) default '0',
  `delete_local` tinyint(1) default '0',
  `delete_datastore` tinyint(1) default '1',
  `delete_dxlayer` tinyint(1) default '1',
  `epoch` timestamp NOT NULL default '0000-00-00 00:00:00',
  `survey` varchar(10) default NULL,
  `psps_survey` varchar(10) default NULL,
  `queue_P2` tinyint(1) default '1',
  `queue_ST` tinyint(1) default '0',
  `queue_OB` tinyint(1) default '0',
  `queue_DF` tinyint(1) default '0',
  `queue_DO` tinyint(1) default '0',
  `queue_FW` tinyint(1) default '0',
  `queue_FO` tinyint(1) default '0',
  `active` tinyint(1) default '1',
  `parallel` tinyint(1) default '0',
  `P2_smf_version` varchar(16) default NULL,
  `ST_cmf_version` varchar(16) default NULL, 
  `trange_start`  timestamp NOT NULL default '0000-00-00 00:00:00',
  `trange_end` timestamp NOT NULL default '0000-00-00 00:00:00',  
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `box` needs to be after skychunk or get err:150
--

DROP TABLE IF EXISTS `box`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `box` (
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `skychunk` varchar(30) default NULL,
  `ra_center` float default NULL,
  `dec_center` float default NULL,
  `box_side` float default NULL,
  `ingested` varchar(64) default 'none',
  PRIMARY KEY  (`id`),
  KEY `fk_skychunk` (`skychunk`),
  CONSTRAINT `fk_skychunk` FOREIGN KEY (`skychunk`) REFERENCES `skychunk` (`name`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `detection`
--

DROP TABLE IF EXISTS `detection`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `detection` (
  `batch_id` bigint(20) unsigned NOT NULL,
  `exp_id` bigint(20) default NULL,
  `filter` varchar(1) default NULL,
  KEY `batch_id` (`batch_id`),
  CONSTRAINT `detection_ibfk_1` FOREIGN KEY (`batch_id`) REFERENCES `batch` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `forcedwarp`
--

DROP TABLE IF EXISTS `forcedwarp`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `forcedwarp` (
  `batch_id` bigint(20) unsigned NOT NULL,
  `exp_id` bigint(20) default NULL,
  `filter` varchar(1) default NULL,
  KEY `batch_id` (`batch_id`),
  CONSTRAINT `forcedwarpd_ibfk_1` FOREIGN KEY (`batch_id`) REFERENCES `batch` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `object`
--

DROP TABLE IF EXISTS `object`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `object` (
  `batch_id` bigint(20) unsigned NOT NULL,
  `region` varchar(50) default NULL,
  KEY `batch_id` (`batch_id`),
  CONSTRAINT `object_fk_1` FOREIGN KEY (`batch_id`) REFERENCES `batch` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
--
-- Table structure for table `diffobject`
--

DROP TABLE IF EXISTS `diffobject`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `diffobject` (
  `batch_id` bigint(20) unsigned NOT NULL,
  `region` varchar(50) default NULL,
  KEY `batch_id` (`batch_id`),
  CONSTRAINT `diffobject_fk_1` FOREIGN KEY (`batch_id`) REFERENCES `batch` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `pending`
--

DROP TABLE IF EXISTS `pending`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `pending` (
  `box_id` bigint(20) unsigned default NULL,
  `batch_type` varchar(10) default NULL,
  `stage_id` bigint(20) default NULL,
  UNIQUE KEY `a_key` (`box_id`,`stage_id`,`batch_type`),
  UNIQUE KEY `stage_id_key` (`stage_id`,`batch_type`),
  CONSTRAINT `box_key` FOREIGN KEY (`box_id`) REFERENCES `box` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `stack`
--

DROP TABLE IF EXISTS `stack`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `stack` (
  `batch_id` bigint(20) unsigned NOT NULL,
  `filter` varchar(1) default NULL,
  `stack_type` varchar(20) default NULL,
  KEY `batch_id` (`batch_id`),
  CONSTRAINT `stack_ibfk_1` FOREIGN KEY (`batch_id`) REFERENCES `batch` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `diff`
--

DROP TABLE IF EXISTS `diff`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `diff` (
  `batch_id` bigint(20) unsigned NOT NULL,
  `filter` varchar(1) default NULL,
  `diff_type` varchar(20) default NULL,
  KEY `batch_id` (`batch_id`),
  CONSTRAINT `diff_ibfk_1` FOREIGN KEY (`batch_id`) REFERENCES `batch` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `stripe`
--

DROP TABLE IF EXISTS `stripe`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `stripe` (
  `client_id` bigint(20) unsigned default NULL,
  `skychunk` varchar(30) default NULL,
  `ra_center` float default NULL,
  UNIQUE KEY `unique_key` (`client_id`),
  CONSTRAINT `stripe_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2012-04-10  6:00:59


DROP TABLE IF EXISTS `dvodb`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `dvodb` (
  `dvo_db` varchar(30) default NULL,
  `batch_type` varchar(10) default NULL,
  `stage_id` bigint(20) unsigned default NULL,
  `ra_center` float default NULL,
  `dec_center` float default NULL,
  `uniq_key` varchar(30) default NULL,
  UNIQUE KEY `uniq_key` (`uniq_key`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;


