text: -- phpMyAdmin SQL Dump
  -- version 3.4.10.1deb1
  -- http://www.phpmyadmin.net
  --
  -- Host: localhost
  -- Generation Time: Oct 11, 2014 at 04:54 PM
  -- Server version: 5.5.35
  -- PHP Version: 5.3.10-1ubuntu3.11
  
  SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
  SET time_zone = "+00:00";
  
  
  /*!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 */;
  
  --
  -- Database: `instasynch`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `bans`
  --
  
  CREATE TABLE IF NOT EXISTS `bans` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `ip` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `room_name` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `user_id` int(11) DEFAULT NULL,
    `username` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `loggedin` tinyint(1) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `room_name` (`room_name`,`user_id`),
    KEY `user_id` (`user_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9027 ;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `friends_list`
  --
  
  CREATE TABLE IF NOT EXISTS `friends_list` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `userA` int(11) NOT NULL,
    `userB` int(11) NOT NULL,
    `sentBy` int(11) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `userA` (`userA`,`userB`),
    KEY `sentBy` (`sentBy`),
    KEY `userB` (`userB`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9704 ;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `friend_requests`
  --
  
  CREATE TABLE IF NOT EXISTS `friend_requests` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `userA` int(11) NOT NULL,
    `userB` int(11) NOT NULL,
    `sentBy` int(11) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `userA` (`userA`,`userB`),
    KEY `sentBy` (`sentBy`),
    KEY `userB` (`userB`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13590 ;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `ips`
  --
  
  CREATE TABLE IF NOT EXISTS `ips` (
    `ip` varchar(45) NOT NULL,
    `count` int(3) NOT NULL,
    PRIMARY KEY (`ip`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `mods`
  --
  
  CREATE TABLE IF NOT EXISTS `mods` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `room_name` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `username` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `permissions` int(11) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `room` (`room_name`,`username`),
    KEY `user_id` (`username`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6930 ;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `resets`
  --
  
  CREATE TABLE IF NOT EXISTS `resets` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `token` varchar(73) NOT NULL,
    `user_id` int(11) NOT NULL,
    `time` int(11) NOT NULL,
    `ip` varchar(45) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `token` (`token`),
    KEY `user_id` (`user_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1188 ;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `rooms`
  --
  
  CREATE TABLE IF NOT EXISTS `rooms` (
    `room_id` int(11) NOT NULL,
    `room_name` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
    `description` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL,
    `users` int(11) NOT NULL,
    `thumbnail` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL,
    `visits` int(11) NOT NULL,
    `title` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
    `listing` enum('public','private') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'public',
    `info` varchar(2048) COLLATE utf8_unicode_ci NOT NULL,
    `NSFW` int(1) NOT NULL DEFAULT '0',
    PRIMARY KEY (`room_id`),
    UNIQUE KEY `roomname` (`room_name`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `users`
  --
  
  CREATE TABLE IF NOT EXISTS `users` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `username` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
    `hashpw` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
    `cookie` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
    `email` varchar(256) COLLATE utf8_unicode_ci NOT NULL,
    `avatar` varchar(7) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'YfyWjq4',
    `bio` varchar(1024) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'No Bio',
    `social` tinyint(1) NOT NULL DEFAULT '1',
    `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `username` (`username`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=65130 ;
  
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `bans`
  --
  ALTER TABLE `bans`
    ADD CONSTRAINT `bans_ibfk_1` FOREIGN KEY (`room_name`) REFERENCES `rooms` (`room_name`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `bans_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Constraints for table `friends_list`
  --
  ALTER TABLE `friends_list`
    ADD CONSTRAINT `friends_list_ibfk_3` FOREIGN KEY (`sentBy`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `friends_list_ibfk_4` FOREIGN KEY (`userA`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `friends_list_ibfk_5` FOREIGN KEY (`userB`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Constraints for table `friend_requests`
  --
  ALTER TABLE `friend_requests`
    ADD CONSTRAINT `friend_requests_ibfk_1` FOREIGN KEY (`userA`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `friend_requests_ibfk_2` FOREIGN KEY (`userB`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `friend_requests_ibfk_3` FOREIGN KEY (`sentBy`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Constraints for table `mods`
  --
  ALTER TABLE `mods`
    ADD CONSTRAINT `mods_ibfk_3` FOREIGN KEY (`room_name`) REFERENCES `rooms` (`room_name`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `mods_ibfk_4` FOREIGN KEY (`username`) REFERENCES `users` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Constraints for table `resets`
  --
  ALTER TABLE `resets`
    ADD CONSTRAINT `resets_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Constraints for table `rooms`
  --
  ALTER TABLE `rooms`
    ADD CONSTRAINT `rooms_ibfk_1` FOREIGN KEY (`room_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `rooms_ibfk_2` FOREIGN KEY (`room_name`) REFERENCES `users` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  /*!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 */;
  