-- phpMyAdmin SQL Dump
-- version 2.11.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 28, 2009 at 07:08 AM
-- Server version: 5.0.32
-- PHP Version: 5.2.0-8+etch13

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `linkable`
--

-- --------------------------------------------------------

--
-- Table structure for table `clusters`
--

DROP TABLE IF EXISTS `clusters`;
CREATE TABLE IF NOT EXISTS `clusters` (
  `id` int(11) NOT NULL auto_increment,
  `user_id` int(10) NOT NULL,
  `name` varchar(32) default NULL,
  `tags` varchar(100) default NULL,
  PRIMARY KEY  (`id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;

-- --------------------------------------------------------

-- 
-- Table structure for table `favicons`
-- 
DROP TABLE IF EXISTS `favicons`;
CREATE TABLE `favicons` (
  `id` int(11) NOT NULL auto_increment,
  `domain` varchar(128) default NULL,
  `status` int(11) default NULL COMMENT '1 - queued,2-processing,0-failed,4-ready,3-requeued',
  `thread_id` int(11) default NULL,
  `updated` datetime default NULL,
  `created` datetime default NULL,
  `hash` char(32) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `domain` (`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------
--
-- Table structure for table `homes`
--

DROP TABLE IF EXISTS `homes`;
CREATE TABLE IF NOT EXISTS `homes` (
  `id` tinyint(10) NOT NULL,
  `name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `links`
--

DROP TABLE IF EXISTS `links`;
CREATE TABLE IF NOT EXISTS `links` (
  `id` int(11) NOT NULL auto_increment,
  `cluster_id` int(10) NOT NULL,
  `title` varchar(32) default NULL,
  `url` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `cluster_id` (`cluster_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=26 ;


alter table links add user_id integer null references users  after cluster_id;

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
  `username` varchar(50) NOT NULL,
  `password` varchar(100) NOT NULL,
  `id` int(11) NOT NULL auto_increment,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `clusters`
--
ALTER TABLE `clusters`
  ADD CONSTRAINT `clusters_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `links`
--
ALTER TABLE `links`
  ADD CONSTRAINT `links_ibfk_1` FOREIGN KEY (`cluster_id`) REFERENCES `clusters` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
ALTER TABLE `links` ADD `position` INT( 10 ) NOT NULL DEFAULT '0';

ALTER TABLE `clusters` 
ADD `position` INT( 10 ) NOT NULL DEFAULT '0',ADD `column_id` INT( 10 ) NOT NULL DEFAULT '0';

ALTER TABLE `users` ADD `email` VARCHAR( 200 ) NULL ,
ADD `securecode` VARCHAR( 100 ) NULL ;
