# ************************************************************
# Sequel Pro SQL dump
# Version 4096
#
# http://www.sequelpro.com/
# http://code.google.com/p/sequel-pro/
#
# Host: localhost (MySQL 5.5.38)
# Database: iris
# Generation Time: 2015-06-16 18:00:36 +0000
# ************************************************************




# Dump of table addresses
# ------------------------------------------------------------


CREATE TABLE `addresses` (
  `address_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `address_street_1` varchar(255) DEFAULT NULL,
  `address_street_2` varchar(255) DEFAULT NULL,
  `address_city` varchar(255) DEFAULT NULL,
  `address_state` varchar(2) DEFAULT NULL,
  `address_zip` char(10) DEFAULT NULL,
  `address_country` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`address_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Dump of table profiles
# ------------------------------------------------------------


CREATE TABLE `profiles` (
  `profile_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `address_id` int(11) unsigned DEFAULT NULL,
  `profile_slug` varchar(255) DEFAULT NULL,
  `profile_first_name` varchar(255) DEFAULT NULL,
  `profile_last_name` varchar(255) DEFAULT NULL,
  `profile_dob` date DEFAULT NULL,
  `profile_title` varchar(255) DEFAULT NULL,
  `profile_avatar` varchar(255) DEFAULT NULL,
  `profile_content` mediumtext,
  `profile_phone` varchar(50) DEFAULT NULL,
  `profile_public` tinyint(1) NOT NULL DEFAULT '0',
  `profile_index` int(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`profile_id`),
  UNIQUE KEY `profile_slug` (`profile_slug`),
  KEY `address_id` (`address_id`),
  CONSTRAINT `profiles_ibfk_1` FOREIGN KEY (`address_id`) REFERENCES `addresses` (`address_id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Dump of table role_permissions
# ------------------------------------------------------------


CREATE TABLE `role_permissions` (
  `role_permission_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `role_id` int(11) unsigned NOT NULL,
  `permission_id` int(11) unsigned NOT NULL,
  PRIMARY KEY (`role_permission_id`),
  UNIQUE KEY `role_id_2` (`role_id`,`permission_id`),
  KEY `role_id` (`role_id`),
  KEY `permission_id` (`permission_id`),
  CONSTRAINT `role_permissions_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `roles` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `role_permissions_ibfk_2` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`permission_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Dump of table user_logins
# ------------------------------------------------------------


CREATE TABLE `user_logins` (
  `user_login_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) unsigned NOT NULL,
  `user_login_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`user_login_id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `user_logins_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



# Dump of table user_roles
# ------------------------------------------------------------


CREATE TABLE `user_roles` (
  `user_role_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) unsigned NOT NULL,
  `role_id` int(11) unsigned NOT NULL,
  PRIMARY KEY (`user_role_id`),
  KEY `user_id` (`user_id`),
  KEY `role_id` (`role_id`),
  CONSTRAINT `user_roles_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `user_roles_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `roles` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `role_permissions` (`role_permission_id`, `role_id`, `permission_id`)
VALUES
	(NULL, 1, LAST_INSERT_ID()),
	(NULL, 2, LAST_INSERT_ID());

INSERT INTO `role_permissions` (`role_permission_id`, `role_id`, `permission_id`)
VALUES
	(NULL, 1, LAST_INSERT_ID()),
	(NULL, 2, LAST_INSERT_ID());

INSERT INTO `role_permissions` (`role_permission_id`, `role_id`, `permission_id`)
VALUES
	(NULL, 1, LAST_INSERT_ID()),
	(NULL, 2, LAST_INSERT_ID());

INSERT INTO `role_permissions` (`role_permission_id`, `role_id`, `permission_id`)
VALUES
	(NULL, 1, LAST_INSERT_ID()),
	(NULL, 2, LAST_INSERT_ID());

INSERT INTO `role_permissions` (`role_permission_id`, `role_id`, `permission_id`)
VALUES
	(NULL, 1, LAST_INSERT_ID()),
	(NULL, 2, LAST_INSERT_ID());

INSERT INTO `role_permissions` (`role_permission_id`, `role_id`, `permission_id`)
VALUES
	(NULL, 1, LAST_INSERT_ID());

INSERT INTO `role_permissions` (`role_permission_id`, `role_id`, `permission_id`)
VALUES
	(NULL, 1, LAST_INSERT_ID());



