-- -------------------------------------------------------------------------------------------------------------- -- Company -- -------------------------------------------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `qs_Company` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `address` varchar(255) NOT NULL, `address2` varchar(255) NOT NULL, `city` varchar(255) NOT NULL, `state` char(2) NOT NULL, `zip` varchar(16) NOT NULL, `phone` varchar(255) NOT NULL, `fax` varchar(255) NOT NULL, `websiteUrl` varchar(255) NOT NULL, `added` datetime NOT NULL, `changed` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------------------------------------------------------------- -- End Company -- -------------------------------------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------------------------------------- -- Membership Type -- -------------------------------------------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `qs_MembershipType` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `price` decimal(11,2) NOT NULL, `summary` text NOT NULL, `sorter` int(11) NOT NULL, `added` datetime NOT NULL, `changed` datetime NOT NULL, PRIMARY KEY (`id`), KEY `sorter` (`sorter`) ) ENGINE=InnoDB; INSERT INTO `qs_MembershipType` (`id`, `title`, `price`, `summary`, `sorter`, `added`, `changed`) VALUES (1, 'General Member', 100, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eu volutpat felis, ut sollicitudin turpis. In commodo in quam in pretium. Donec et dictum nisl. Nunc vel orci sapien. Fusce pulvinar nec nibh sollicitudin condimentum. Donec dapibus nulla libero, vel dapibus libero tincidunt vel. Integer sed eros eu justo volutpat rutrum id in mi.', 0, '2014-02-13 12:15:45', '2014-02-13 12:15:45'), (2, 'Affiliate Member', 150, 'Maecenas erat nunc, blandit id hendrerit id, dictum vitae eros. Vivamus interdum lacinia lorem, id placerat metus tristique vel. Aliquam varius pharetra mauris, at tincidunt nulla posuere at. Ut malesuada, arcu nec gravida tempor, massa erat aliquam mauris, a porttitor enim nisi nec lacus. Mauris sed arcu dolor. Nullam mattis vehicula sem, ac sollicitudin lectus suscipit ac. Nam nec bibendum magna, nec sollicitudin tortor.', 2, '2014-02-13 12:15:45', '2014-02-13 12:15:45'); -- -------------------------------------------------------------------------------------------------------------- -- End Membership Type -- -------------------------------------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------------------------------------- -- Individual -- -------------------------------------------------------------------------------------------------------------- ALTER TABLE `qs_UserAddress` ADD `address2` VARCHAR( 255 ) NOT NULL AFTER `address`; ALTER TABLE `qs_UserAddress` CHANGE `type` `type` SET( 'home', 'billing', 'shipping', 'company' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; ALTER TABLE `qs_User` ADD `companyName` VARCHAR( 255 ) NOT NULL AFTER `lastName` , ADD `companyPhone` VARCHAR( 255 ) NOT NULL AFTER `companyName` , ADD `companyFax` VARCHAR( 255 ) NOT NULL AFTER `companyPhone`; ALTER TABLE `qs_User` ADD `status` CHAR(8) DEFAULT NULL AFTER `recoverCodeExpirationDate`, ADD INDEX ( `status` ); CREATE TABLE IF NOT EXISTS `qs_UserStatus` ( `id` CHAR(8) NOT NULL, `title` varchar(32) NOT NULL, `sorter` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `sorter` (`sorter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `qs_UserStatus` (`id`, `title`, `sorter`) VALUES ('active', 'Active', 0), ('inactive', 'Inactive', 1); ALTER TABLE `qs_User` ADD FOREIGN KEY ( `status` ) REFERENCES `qs_UserStatus` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE; ALTER TABLE `qs_User` ADD `companyId` INT UNSIGNED NULL DEFAULT NULL AFTER `lastName` , ADD INDEX ( `companyId` ); ALTER TABLE `qs_User` ADD FOREIGN KEY ( `companyId` ) REFERENCES `qs_Company` (`id`) ON DELETE SET NULL ON UPDATE RESTRICT ; ALTER TABLE `qs_User` ADD `alias` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `lastName` , ADD `metaTitle` VARCHAR( 255 ) NOT NULL AFTER `alias` , ADD `metaKeywords` TEXT NOT NULL AFTER `metaTitle` , ADD `metaDescription` TEXT NOT NULL AFTER `metaKeywords` , ADD UNIQUE (`alias`); ALTER TABLE `qs_User` ADD `bought` ENUM( 'y' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'null - record in cart; ''y'' - account purchased and available on the admin end' AFTER `id`, ADD INDEX ( `bought` ); ALTER TABLE `qs_User` DROP INDEX email; ALTER TABLE `qs_User` ADD UNIQUE (`bought`,`email`); ALTER TABLE `qs_User` ADD `membershipTypeId` INT UNSIGNED NOT NULL AFTER `bought` , ADD INDEX ( `membershipTypeId` ); ALTER TABLE `qs_User` CHANGE `membershipTypeId` `membershipTypeId` INT( 10 ) UNSIGNED NULL DEFAULT NULL; -- UPDATE `qs_User` SET `membershipTypeId` = 1 WHERE `membershipTypeId` = 0; UPDATE `qs_User` SET `membershipTypeId` = NULL WHERE `membershipTypeId` = 0; ALTER TABLE `qs_User` ADD FOREIGN KEY ( `membershipTypeId` ) REFERENCES `qs_MembershipType` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT ; ALTER TABLE `qs_User` CHANGE `phone` `directPhone` VARCHAR( 255 ) NOT NULL; ALTER TABLE `qs_User` ADD `cellPhone` VARCHAR( 255 ) DEFAULT NULL AFTER `directPhone`; ALTER TABLE `qs_User` ADD `photo` VARCHAR( 255 ) DEFAULT NULL AFTER `cellPhone`; ALTER TABLE `qs_User` ADD `bio` TEXT NOT NULL AFTER `photo`; ALTER TABLE `qs_User` ADD `linkedInUrl` VARCHAR( 255 ) NOT NULL AFTER `bio`; ALTER TABLE `qs_User` ADD `joinDate` DATE NOT NULL AFTER `linkedInUrl`; ALTER TABLE `qs_User` ADD `notes` TEXT NOT NULL AFTER `joinDate`; ALTER TABLE `qs_User` ADD `leadershipGroupId` INT UNSIGNED DEFAULT NULL AFTER `notes` , ADD `leadershipPosition` VARCHAR( 255 ) NOT NULL AFTER `leadershipGroupId` , ADD INDEX ( `leadershipGroupId` ); ALTER TABLE `qs_User` DROP `enabled`; ALTER TABLE `qs_User` ADD `sorter` INT NOT NULL AFTER `leadershipPosition` , ADD INDEX ( `sorter` ); -- vityk's changes started CREATE TABLE IF NOT EXISTS `qs_UserRegistrationCompany` ( `userId` int(11) unsigned NOT NULL DEFAULT '0', `name` varchar(255) NOT NULL, `phone` varchar(255) NOT NULL, `fax` varchar(255) NOT NULL, `address` varchar(255) NOT NULL, `address2` varchar(255) NOT NULL, `city` varchar(255) NOT NULL, `state` char(2) NOT NULL, `zip` varchar(16) NOT NULL, PRIMARY KEY (`userId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `qs_UserRegistrationCompany` CHANGE `userId` `userId` INT( 11 ) UNSIGNED NULL DEFAULT NULL ; ALTER TABLE `qs_UserRegistrationCompany` ADD FOREIGN KEY ( `userId` ) REFERENCES `qs_User` ( `id` ) ON DELETE CASCADE ON UPDATE NO ACTION ; ALTER TABLE `qs_User` DROP `companyName`, DROP `companyPhone`, DROP `companyFax`; ALTER TABLE `qs_UserAddress` CHANGE `type` `type` SET( 'home', 'billing', 'shipping' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; ALTER TABLE `qs_User` CHANGE `joinDate` `joinDate` DATE NULL DEFAULT NULL; -- vityk's changes finish -- -------------------------------------------------------------------------------------------------------------- -- End Individuals -- -------------------------------------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------------------------------------- -- Lists -- -------------------------------------------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `qs_List` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `sorter` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `sorter` (`sorter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `qs_UserList` ( `userId` int(10) unsigned NOT NULL, `listId` int(10) unsigned NOT NULL, PRIMARY KEY (`userId`,`listId`), KEY `listId` (`listId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `qs_UserList` ADD FOREIGN KEY (`listId`) REFERENCES `qs_List` (`id`) ON DELETE CASCADE, ADD FOREIGN KEY (`userId`) REFERENCES `qs_User` (`id`) ON DELETE CASCADE; -- -------------------------------------------------------------------------------------------------------------- -- End Lists -- -------------------------------------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------------------------------------- -- Leadership Groups -- -------------------------------------------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `qs_LeadershipGroup` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `enabled` enum('y','n') NOT NULL, `sorter` int(11) NOT NULL, `added` datetime NOT NULL, `changed` datetime NOT NULL, PRIMARY KEY (`id`), KEY `enabled` (`enabled`), KEY `sorter` (`sorter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; ALTER TABLE `qs_User` ADD FOREIGN KEY (`leadershipGroupId`) REFERENCES `qs_LeadershipGroup` (`id`) ON DELETE SET NULL ON UPDATE RESTRICT ; -- -------------------------------------------------------------------------------------------------------------- -- End Leadership Groups -- -------------------------------------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------------------------------------- -- Committee -- -------------------------------------------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `qs_Committee` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `alias` varchar(255) NOT NULL, `metaTitle` varchar(255) NOT NULL, `metaKeywords` text NOT NULL, `metaDescription` text NOT NULL, `purpose` text NOT NULL, `enabled` enum('y','n') NOT NULL, `sorter` int(11) NOT NULL, `added` datetime NOT NULL, `changed` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `alias` (`alias`), KEY `enabled` (`enabled`,`sorter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `qs_CommitteePosition` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `sorter` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `sorter` (`sorter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; INSERT INTO `qs_CommitteePosition` (`id`, `title`, `sorter`) VALUES (1, 'Chair', 0), (2, 'Member', 1); CREATE TABLE IF NOT EXISTS `qs_UserCommittee` ( `userId` int(10) unsigned NOT NULL, `committeeId` int(10) unsigned NOT NULL, `positionId` int(10) unsigned NOT NULL, PRIMARY KEY (`userId`,`committeeId`), KEY `positionId` (`positionId`), KEY `committeeId` (`committeeId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `qs_UserCommittee` ADD FOREIGN KEY (`positionId`) REFERENCES `qs_CommitteePosition` (`id`), ADD FOREIGN KEY (`userId`) REFERENCES `qs_User` (`id`) ON DELETE CASCADE, ADD FOREIGN KEY (`committeeId`) REFERENCES `qs_Committee` (`id`) ON DELETE CASCADE; -- -------------------------------------------------------------------------------------------------------------- -- End Committee -- -------------------------------------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------------------------------------- -- Events -- -------------------------------------------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `qs_Event` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `type` char(16) NOT NULL, `alias` varchar(255) NOT NULL, `metaTitle` varchar(255) NOT NULL, `metaKeywords` TEXT NOT NULL, `metaDescription` TEXT NOT NULL, `committeeId` int(10) unsigned DEFAULT NULL, `durationType` enum('singleDay','multipleDays') NOT NULL, `title` varchar(255) NOT NULL, `image` varchar(255) NOT NULL, `startDate` date NOT NULL, `endDate` date NOT NULL, `registrationStart` datetime DEFAULT NULL, `registrationEnd` datetime DEFAULT NULL, `location` varchar(255) NOT NULL, `mapUrl` varchar(255) DEFAULT NULL, `description` text NOT NULL, `memberPrice` decimal(11,2) DEFAULT NULL, `nonmemberPrice` decimal(11,2) DEFAULT NULL, `registrationLimit` int(10) unsigned DEFAULT NULL, `enabled` enum('n','y') NOT NULL DEFAULT 'n', `added` datetime NOT NULL, `changed` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `alias` (`alias`), KEY `type` (`type`,`startDate`,`endDate`,`enabled`), KEY `registrationStart` (`registrationStart`), KEY `registrationEnd` (`registrationEnd`), KEY `committeeId` (`committeeId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `qs_EventTime` ( `eventId` int(10) unsigned NOT NULL, `date` date NOT NULL, `startTime` time NOT NULL, `endTime` time NOT NULL, PRIMARY KEY (`eventId`,`date`), KEY `date` (`date`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `qs_EventType` ( `id` CHAR(16) NOT NULL, `title` varchar(32) NOT NULL, `sorter` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `sorter` (`sorter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `qs_Event` ADD FOREIGN KEY (`type`) REFERENCES `qs_EventType` (`id`) ON UPDATE CASCADE; ALTER TABLE `qs_Event` ADD FOREIGN KEY (`committeeId`) REFERENCES `qs_Committee` (`id`); INSERT INTO `qs_EventType` (`id`, `title`, `sorter`) VALUES ('registration', 'Registration Event', 0), ('committee', 'Committee Event', 1); ALTER TABLE `qs_EventTime` ADD FOREIGN KEY (`eventId`) REFERENCES `qs_Event` (`id`) ON DELETE CASCADE; ALTER TABLE `qs_Event` ADD FOREIGN KEY (`type`) REFERENCES `qs_EventType` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE; CREATE TABLE IF NOT EXISTS `qs_EventAttendee` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `eventId` int(10) unsigned NOT NULL, `cartId` int(11) NOT NULL, `type` enum('member','nonmember') NOT NULL, `userId` int(10) unsigned DEFAULT NULL, `createdBy` char(16) NOT NULL, `createdByName` varchar(255) NOT NULL, `bought` enum('y') DEFAULT NULL COMMENT 'this field should be set to ''y'' after Cart.transactionId is set to NOT NULL value', `firstName` varchar(255) NOT NULL COMMENT 'save name in case user will be removed', `lastName` varchar(255) NOT NULL, `email` varchar(128) NOT NULL, `company` varchar(255) DEFAULT NULL, `paymentType` char(16) DEFAULT NULL, `paymentDate` date DEFAULT NULL, `registrationDate` datetime DEFAULT NULL COMMENT 'this field should be set automatically when order is submitted or attendee added from admin end.', `amount` decimal(11,2) NOT NULL, `status` char(8) NOT NULL DEFAULT 'enrolled', `added` datetime NOT NULL, `changed` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `eventId_attendee_name` (`eventId`,`bought`,`firstName`,`lastName`), KEY `userId` (`userId`), KEY `type` (`type`), KEY `email` (`email`), KEY `bought` (`bought`), KEY `paymentType` (`paymentType`), KEY `status` (`status`), KEY `createdBy` (`createdBy`), KEY `registrationDate` (`registrationDate`), KEY `cartId` (`cartId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `qs_EventAttendeeCreatedBy` ( `id` CHAR(16) NOT NULL, `title` varchar(255) NOT NULL, `sorter` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `sorter` (`sorter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `qs_EventAttendeeCreatedBy` (`id`, `title`, `sorter`) VALUES ('me', 'Me', 0), ('anotherMember', 'Another Member', 1), ('admin', 'Administrator', 2); CREATE TABLE IF NOT EXISTS `qs_EventAttendeeStatus` ( `id` CHAR(8) NOT NULL, `title` varchar(64) NOT NULL, `sorter` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `sorter` (`sorter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `qs_EventAttendeeStatus` (`id`, `title`, `sorter`) VALUES ('enrolled', 'Enrolled', 0), ('attended', 'Attended', 1), ('canceled', 'Cancelled', 2), ('noShow', 'No Show', 3); CREATE TABLE IF NOT EXISTS `qs_EventAttendeeType` ( `id` enum('member','nonmember') NOT NULL, `title` varchar(32) NOT NULL, `sorter` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `sorter` (`sorter`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `qs_EventAttendeeType` (`id`, `title`, `sorter`) VALUES ('member', 'Member', 0), ('nonmember', 'Nonmember', 1); CREATE TABLE IF NOT EXISTS `qs_PaymentType` ( `id` CHAR(16) NOT NULL, `title` varchar(64) NOT NULL, `showFor` set('user','admin') NOT NULL, `sorter` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `sorter` (`sorter`), KEY `showFor` (`showFor`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `qs_PaymentType` (`id`, `title`, `showFor`, `sorter`) VALUES ('authorizeNet', 'Credit Card - Online', 'user,admin', 0), ('ccAdmin', 'Credit Card - Admin', 'admin', 1), ('po', 'P.O.', 'user,admin', 3), ('check', 'Check', 'admin', 4), ('cash', 'Cash', 'admin', 5), ('comp', 'Comp', 'admin', 6); ALTER TABLE `qs_EventAttendee` ADD FOREIGN KEY (`cartId`) REFERENCES `qs_Cart` (`id`), ADD FOREIGN KEY (`userId`) REFERENCES `qs_User` (`id`) ON DELETE SET NULL, ADD FOREIGN KEY (`type`) REFERENCES `qs_EventAttendeeType` (`id`) ON UPDATE CASCADE, ADD FOREIGN KEY (`eventId`) REFERENCES `qs_Event` (`id`) ON DELETE CASCADE, ADD FOREIGN KEY (`paymentType`) REFERENCES `qs_PaymentType` (`id`) ON UPDATE CASCADE, ADD FOREIGN KEY (`status`) REFERENCES `qs_EventAttendeeStatus` (`id`) ON UPDATE CASCADE, ADD FOREIGN KEY (`createdBy`) REFERENCES `qs_EventAttendeeCreatedBy` (`id`) ON UPDATE CASCADE ; -- -------------------------------------------------------------------------------------------------------------- -- End Events -- -------------------------------------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------------------------------------- -- Cart -- -------------------------------------------------------------------------------------------------------------- ALTER TABLE `qs_CartItem` CHANGE `cartItemType` `cartItemType` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; CREATE TABLE IF NOT EXISTS `qs_CartItemType` ( `id` varchar(64) NOT NULL, `title` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; SET foreign_key_checks = 0; TRUNCATE `qs_CartItem`; TRUNCATE `qs_Transaction`; TRUNCATE `qs_Cart`; SET foreign_key_checks = 1; ALTER TABLE `qs_CartItem` ADD FOREIGN KEY ( `cartItemType` ) REFERENCES `qs_CartItemType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; INSERT INTO `qs_CartItemType` (`id`, `title`) VALUES ('ECommerce_Product_', 'Product'), ('User\\Register\\', 'Individual Registration'); -- -------------------------------------------------------------------------------------------------------------- -- End Cart -- -------------------------------------------------------------------------------------------------------------- -- -------------------------------------------------------------------------------------------------------------- -- Settings -- -------------------------------------------------------------------------------------------------------------- update `qs_Settings` SET `description` = replace(`description`, '{phone}', '{directPhone}') WHERE `name` = 'userRegistrationEmailBody'; update `qs_Settings` SET `description` = replace(`description`, '{phone}', '{directPhone}') WHERE `name` = 'userRegistrationAdminEmailBody'; update `qs_Settings` SET `description` = replace(`description`, '{phone}', '{directPhone}') WHERE `name` = 'changePasswordEmailBody'; update `qs_Settings` SET `value` = replace(`value`, '{phone}', '{directPhone}') WHERE `name` = 'userRegistrationEmailBody'; update `qs_Settings` SET `value` = replace(`value`, '{phone}', '{directPhone}') WHERE `name` = 'userRegistrationAdminEmailBody'; update `qs_Settings` SET `value` = replace(`value`, '{phone}', '{directPhone}') WHERE `name` = 'changePasswordEmailBody'; -- -------------------------------------------------------------------------------------------------------------- -- End Settings -- --------------------------------------------------------------------------------------------------------------