From c3a786cc32e781003ee1c2b46ef350ad303f7aa3 Mon Sep 17 00:00:00 2001 From: vatseek Date: Thu, 29 Nov 2012 17:18:57 +0200 Subject: [PATCH] change context use way --- tests/LoadFixtures.php | 40 +- tests/Readme.RU.md | 60 ++ tests/behat/features/base.feature | 12 +- .../features/bootstrap/BaseFeatureContext.php | 146 ++- .../features/bootstrap/FeatureContext.php | 14 +- tests/fixtures/BlogFixtures.php | 4 +- tests/fixtures/TopicFixtures.php | 20 +- tests/fixtures/UserFixtures.php | 55 +- tests/fixtures/sql/insert.sql | 45 + tests/fixtures/sql/install_base.sql | 991 ++++++++++++++++++ 10 files changed, 1320 insertions(+), 67 deletions(-) create mode 100644 tests/Readme.RU.md create mode 100644 tests/fixtures/sql/insert.sql create mode 100644 tests/fixtures/sql/install_base.sql diff --git a/tests/LoadFixtures.php b/tests/LoadFixtures.php index 97ef4ee1..42115a24 100644 --- a/tests/LoadFixtures.php +++ b/tests/LoadFixtures.php @@ -28,9 +28,8 @@ class LoadFixtures */ private $sDirFixtures; - public function __construct() { - $this->oEngine = Engine::getInstance(); - $this->oEngine->Init(); + public function __construct($oEngine) { + $this->oEngine = $oEngine; $this->sDirFixtures = realpath((dirname(__FILE__)) . "/fixtures/"); } @@ -53,7 +52,7 @@ class LoadFixtures WHERE TABLE_SCHEMA = '" . $sDbname . "'"); mysql_query('SET FOREIGN_KEY_CHECKS = 0'); - echo "TRUNCATE TABLE FROM TEST BASE"; + echo "TRUNCATE TABLE FROM TEST BASE\n"; while ($row = mysql_fetch_row($result)) { if (!mysql_query($row[0])) { // exception @@ -74,15 +73,15 @@ class LoadFixtures mysql_select_db($sDbname); - // Load dump from sql.sql - $result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/sql.sql'); + // Load dump from install_base.sql + $result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/install_base.sql'); if (!$result['result']) { // exception - throw new Exception("DB is not exported with file sql.sql"); + throw new Exception("DB is not exported with file install_base.sql"); return $result['errors']; } - echo "ExportSQL DATABASE $sDbname -> sql.sql \n"; + echo "ExportSQL DATABASE $sDbname -> install_base.sql \n"; // Load dump from geo_base.sql $result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/geo_base.sql'); @@ -95,6 +94,17 @@ class LoadFixtures } } + + // Load dump from INSERT_BASE (SQL-Query) + $result = $this->oEngine->Database_ExportSQL(dirname(__FILE__) . '/fixtures/sql/insert.sql'); + + if (!$result['result']) { + // exception + throw new Exception("DB is not exported with file insert.sql"); + return $result['errors']; + } + echo "Export INSERT SQL to DATABASE $sDbname\n"; + return true; } @@ -124,6 +134,9 @@ class LoadFixtures foreach ($aClassNames as $sClassName) { // @todo референсы дублируются в каждом объекте фиксту + в этом объекте $oFixtures = new $sClassName($this->oEngine, $this->aReferences); + if (!$oFixtures instanceof AbstractFixtures) { + throw new Exception($sClassName . " must extend of AbstractFixtures"); + } $oFixtures->load(); $aFixtureReference = $oFixtures->getReferences(); $this->aReferences = array_merge($this->aReferences, $aFixtureReference); @@ -146,16 +159,7 @@ class LoadFixtures $this->sDirFixtures = $sPath; $this->loadFixtures(); + echo "Load Fixture Plugin ... ---> {$plugin}\n"; } - - /** - * Function of activate plugin - * - * @param string $plugin - */ - public function activationPlugin($plugin){ - $this->oEngine->ModulePlugin_Toggle($plugin,'Activate'); - } - } diff --git a/tests/Readme.RU.md b/tests/Readme.RU.md new file mode 100644 index 00000000..2dc9a4e9 --- /dev/null +++ b/tests/Readme.RU.md @@ -0,0 +1,60 @@ +Запуск функциональных тестов +============================ + +Для запуска тестов проекта нужно: + +1) Переименовать файл config/config.test.php.dist в config/config.test.php и изменить настройки подключения к тестовой БД. +ВАЖНО! Информация в этой БД будет перезаписываться при каждом запуске теста. + +2) В конфиге для Behat (tests/behat/behat.yml) сменить значение опции base_url на хост, под которым проект доступен локально. + +3) Выполнить команду ```cd tests/behat; HTTP_APP_ENV=test php behat.phar```. Примерный вывод результата работы команды: + +``` +DROP DATABASE social_test +CREATE DATABASE social_test +SELECTED DATABASE social_test +ExportSQL DATABASE social_test +ExportSQL DATABASE social_test -> geo_base +Feature: LiveStreet standart features + Test base functionality of LiveStreet + + Scenario: See main page # features/base.feature:4 + Given I am on homepage # FeatureContext::iAmOnHomepage() + When I press "Войти" # FeatureContext::pressButton() + Then the response status code should be 200 # FeatureContext::assertResponseStatus() + + Scenario: See Colective Blog # features/base.feature:9 + Given I am on "/blog/gadgets" # FeatureContext::visit() + Then I should see "Gadgets" # FeatureContext::assertPageContainsText() + Then I should see "Offers latest gadget reviews" # FeatureContext::assertPageContainsText() + + Scenario: See list of blogs # features/base.feature:14 + Given I am on "/blogs/" # FeatureContext::visit() + Then I should see "Gadgets" # FeatureContext::assertPageContainsText() + + Scenario: See All Topic # features/base.feature:18 + Given I am on "/index/newall/" # FeatureContext::visit() + Then I should see "iPad 3 rumored to come this March with quad-core chip and 4G LTE " # FeatureContext::assertPageContainsText() + Then I should see "Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet" # FeatureContext::assertPageContainsText() + + Scenario: See User Profile # features/base.feature:23 + Given I am on "/profile/Golfer/" # FeatureContext::visit() + Then I should see "Sergey Doryba" # FeatureContext::assertPageContainsText() + Then I should see "... Sergey Doryba profile description" # FeatureContext::assertPageContainsText() + +5 scenarios (5 passed) +14 steps (14 passed) +0m2.225s +``` + + +4) Для тестирования плагинов используется команда + HTTP_APP_ENV=test php behat.phar --config='../../plugins/(название плагина)/tests/behat/behat.yml' + + +5) При написании дополнительных тестов используются следующие правила: + а) Доступ из всех контектов з контексту MINK должен производится через функцию getMinkContext() + Пример получения доступа к сессии: $this->getMinkContext()->getSession() + + б) Получение доступа к базовому обьекту Engine производится посредством метода: $this->getEngine() \ No newline at end of file diff --git a/tests/behat/features/base.feature b/tests/behat/features/base.feature index ecdabe86..2fdbee71 100644 --- a/tests/behat/features/base.feature +++ b/tests/behat/features/base.feature @@ -4,9 +4,9 @@ Feature: LiveStreet standart features Scenario: See main page Given I am on homepage Then the response status code should be 200 - + Then I should see "Sony MicroVault Mach USB 3.0 flash drive" - Then I should see "Blogger's name golfer" + Then I should see "Blogger's name user_first" Then I should see "iPad 3 rumored to come this March with quad-core chip and 4G LTE " Then I should see "Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet" @@ -24,7 +24,7 @@ Feature: LiveStreet standart features Then the response status code should be 200 Then I should see "Gadgets" - Then I should see "golfer" + Then I should see "user_first" Scenario: See all new topics Given I am on "/index/newall/" @@ -35,8 +35,8 @@ Feature: LiveStreet standart features Then I should see "Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet" Scenario: See user profile - Given I am on "/profile/Golfer/" + Given I am on "/profile/user_first/" Then the response status code should be 200 - Then I should see "Sergey Doryba" - Then I should see "... Sergey Doryba profile description" + Then I should see "user_first" + Then I should see "... UserFirst profile description" \ No newline at end of file diff --git a/tests/behat/features/bootstrap/BaseFeatureContext.php b/tests/behat/features/bootstrap/BaseFeatureContext.php index 871ca3eb..321e6914 100644 --- a/tests/behat/features/bootstrap/BaseFeatureContext.php +++ b/tests/behat/features/bootstrap/BaseFeatureContext.php @@ -16,22 +16,46 @@ require_once("tests/LoadFixtures.php"); /** * LiveStreet custom feature context */ -class BaseFeatureContext extends MinkContext +class BaseFeatureContext extends BehatContext { - protected static $fixturesLoader = null; + protected $fixturesLoader = null; + protected $oEngine = NULL; + + public function __construct() + { + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; + } + + public function getEngine() + { + return $this->oEngine; + } + + public function initEngine() + { + if(!$this->oEngine) { + $this->oEngine = Engine::getInstance(); + $this->oEngine->Init(); + } + } /** * Get fixtures loader * @return LoadFixtures */ - protected static function getFixturesLoader() + protected function getFixturesLoader() { - if (is_null(self::$fixturesLoader)) { - self::$fixturesLoader = new LoadFixtures(); + if (is_null($this->fixturesLoader)) { + $this->fixturesLoader = new LoadFixtures($this->getEngine()); } - return self::$fixturesLoader; + return $this->fixturesLoader; + } + + public function getMinkContext() + { + return $this->getMainContext(); } /** @@ -39,8 +63,10 @@ class BaseFeatureContext extends MinkContext * * @BeforeScenario */ - public static function prepare($event){ - $fixturesLoader = self::getFixturesLoader(); + public function prepare($event) + { + $this->initEngine(); + $fixturesLoader = $this->getFixturesLoader(); $fixturesLoader->purgeDB(); $fixturesLoader->load(); } @@ -56,22 +82,104 @@ class BaseFeatureContext extends MinkContext $fixturesLoader->loadPluginFixtures($plugin); } - - /** - * @Given /^I am activated plugin "([^"]*)"$/ - */ - public function ActivatedPlugin($plugin) - { - $pluginActivation = new LoadFixtures(); - $pluginActivation->activationPlugin($plugin); - } - /** * @Then /^I wait "([^"]*)"$/ */ public function iWait($time_wait) { - $this->getSession()->wait($time_wait); + $this->getMinkContext()->getSession()->wait($time_wait); } + /** + * Check is sets are present in content + * + * @Then /^the response have sets:$/ + */ + public function ResponseHaveSets( $table) + { + $actual = $this->getMinkContext()->getSession()->getPage()->getContent(); + + foreach ($table->getHash() as $genreHash) { + $regex = '/'.preg_quote($genreHash['value'], '/').'/ui'; + if (!preg_match($regex, $actual)) { + $message = sprintf('The string "%s" was not found anywhere in the HTML response of the current page.', $genreHash['value']); + throw new ExpectationException($message, $this->getMinkContext()->getSession()); + } + } + } + + /** + * @Then /^I should see in element "([^"]*)" values:$/ + */ + public function iShouldSeeInContainerValues($objectId, TableNode $table) + { + $element = $this->getMinkContext()->getSession()->getPage()->find('css', "#{$objectId}"); + + if ($element) { + $content = $element->getHtml(); + + foreach ($table->getHash() as $genreHash) { + $regex = '/'.preg_quote($genreHash['value'], '/').'/ui'; + if (!preg_match($regex, $content)) { + $message = sprintf('The string "%s" was not found anywhere in container', $genreHash['value']); + throw new ExpectationException($message, $this->getMinkContext()->getSession()); + } + } + } + else { + throw new ExpectationException('Container not found', $this->getMinkContext()->getSession()); + } + } + + + /** + * Get content type and compare with set + * + * @Then /^content type is "([^"]*)"$/ + */ + public function contentTypeIs($contentType) + { + $header = $this->getMinkContext()->getSession()->getResponseHeaders(); + + if ($contentType != $header['Content-Type']) { + $message = sprintf('Current content type is "%s", but "%s" expected.', $header['Content-Type'], $contentType); + throw new ExpectationException($message, $this->getMinkContext()->getSession()); + } + } + + /** + * Try to login user + * + * @Then /^I want to login as "([^"]*)"$/ + */ + public function iWantToLoginAs($sUserLogin) + { + $moduleUser = $this->getEngine()->GetModuleObject('ModuleUser'); + + $oUser = $moduleUser->GetUserByLogin($sUserLogin); + if (!$oUser) { + throw new ExpectationException( sprintf('User %s not found', $sUserLogin), $this->getMinkContext()->getSession()); + } + + $moduleUser->Authorization($oUser, true); + $sSessionKey = $moduleUser->GetSessionByUserId($oUser->getId())->getKey(); + + $this->getMinkContext()->getSession()->getDriver()->setCookie("key", $sSessionKey); + } + + /** + * Checking for activity of plugin + * + * @Then /^check is plugin active "([^"]*)"$/ + */ + public function CheckIsPluginActive($sPluginName) + { + $activePlugins = $this->getEngine()->Plugin_GetActivePlugins(); + + if (!in_array($sPluginName, $activePlugins)) { + throw new ExpectationException( sprintf('Plugin %s is not active', $sPluginName), $this->getMinkContext()->getSession()); + } + } + + } diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index 4ddf1abc..e6f56e49 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -1,11 +1,21 @@ parameters = $parameters; + $this->useContext('base', new BaseFeatureContext($parameters)); + } + + public function getMinkContext() + { + return $this->getMainContext(); + } } diff --git a/tests/fixtures/BlogFixtures.php b/tests/fixtures/BlogFixtures.php index e5079418..1e99824e 100644 --- a/tests/fixtures/BlogFixtures.php +++ b/tests/fixtures/BlogFixtures.php @@ -11,11 +11,11 @@ class BlogFixtures extends AbstractFixtures public function load() { - $oUserStfalcon = $this->getReference('user-golfer'); + $oUserFirst = $this->getReference('user-first'); /* @var $oBlogGadgets ModuleBlog_EntityBlog */ $oBlogGadgets = Engine::GetEntity('Blog'); - $oBlogGadgets->setOwnerId($oUserStfalcon->getId()); + $oBlogGadgets->setOwnerId($oUserFirst->getId()); $oBlogGadgets->setTitle("Gadgets"); $oBlogGadgets->setDescription('Offers latest gadget reviews'); $oBlogGadgets->setType('open'); diff --git a/tests/fixtures/TopicFixtures.php b/tests/fixtures/TopicFixtures.php index ddfde830..e4fa654c 100644 --- a/tests/fixtures/TopicFixtures.php +++ b/tests/fixtures/TopicFixtures.php @@ -5,6 +5,7 @@ require_once(realpath((dirname(__FILE__)) . "/../AbstractFixtures.php")); class TopicFixtures extends AbstractFixtures { + protected $aActivePlugins = array(); public static function getOrder() { return 2; @@ -12,23 +13,23 @@ class TopicFixtures extends AbstractFixtures public function load() { - $oUserGolfer = $this->getReference('user-golfer'); + $oUserFirst = $this->getReference('user-first'); $oBlogGadgets = $this->getReference('blog-gadgets'); - $oTopicToshiba = $this->_createTopic($oBlogGadgets->getBlogId(), $oUserGolfer->getId(), + $oTopicToshiba = $this->_createTopic($oBlogGadgets->getBlogId(), $oUserFirst->getId(), 'Toshiba unveils 13.3-inch AT330 Android ICS 4.0 tablet', 'Toshiba is to add a new Android 4.0 ICS to the mass which is known as Toshiba AT330. The device is equipped with a multi-touch capacitive touch display that packs a resolution of 1920 x 1200 pixels. The Toshiba AT330 tablet is currently at its prototype stage. We have very little details about the tablet, knowing that it’ll come equipped with HDMI port, on-board 32GB storage that’s expandable via an full-sized SD card slot. It’ll also have a built-in TV tuner and a collapsible antenna.It’ll also run an NVIDIA Tegra 3 quad-core processor. Other goodies will be a 1.3MP front-facing camera and a 5MP rear-facing camera. Currently, there is no information about its price and availability. A clip is included below showing it in action.', 'gadget', '2012-10-21 00:10:20'); $this->addReference('topic-toshiba', $oTopicToshiba); - $oTopicIpad = $this->_createTopic($oBlogGadgets->getBlogId(), $oUserGolfer->getId(), + $oTopicIpad = $this->_createTopic($oBlogGadgets->getBlogId(), $oUserFirst->getId(), 'iPad 3 rumored to come this March with quad-core chip and 4G LTE', 'Another rumor for the iPad 3 has surfaced with some details given by Bloomberg, claiming that the iPad 3 production is already underway and will be ready for a launch as early as March.', 'apple, ipad', '2012-10-21 1:20:30'); $this->addReference('topic-ipad', $oTopicIpad); - $oPersonalBlogGolfer = $this->oEngine->Blog_GetPersonalBlogByUserId($oUserGolfer->getId()); - $oTopicSony = $this->_createTopic($oPersonalBlogGolfer->getBlogId(), $oUserGolfer->getId(), + $oPersonalBlogGolfer = $this->oEngine->Blog_GetPersonalBlogByUserId($oUserFirst->getId()); + $oTopicSony = $this->_createTopic($oPersonalBlogGolfer->getBlogId(), $oUserFirst->getId(), 'Sony MicroVault Mach USB 3.0 flash drive', 'Want more speeds and better protection for your data? The Sony MicroVault Mach flash USB 3.0 drive is what you need. It offers the USB 3.0 interface that delivers data at super high speeds of up to 5Gbps. It’s also backward compatible with USB 2.0.', 'sony, flash, gadget', '2012-10-21 2:30:40'); @@ -49,6 +50,8 @@ class TopicFixtures extends AbstractFixtures */ private function _createTopic($iBlogId, $iUserId, $sTitle, $sText, $sTags, $sDate) { + $this->aActivePlugins = $this->oEngine->Plugin_GetActivePlugins(); + $oTopic = Engine::GetEntity('Topic'); /* @var $oTopic ModuleTopic_EntityTopic */ $oTopic->setBlogId($iBlogId); @@ -70,6 +73,13 @@ class TopicFixtures extends AbstractFixtures $oTopic->setTextHash(md5($oTopic->getType() . $oTopic->getTextSource() . $oTopic->getTitle())); $oTopic->setTags($sTags); + //with active plugin l10n added a field topic_lang + if (in_array('l10n', $this->aActivePlugins)) { + $oTopic->setTopicLang(Config::Get('lang.current')); + } + // @todo refact this + $oTopic->_setValidateScenario('topic'); + $oTopic->_Validate(); $this->oEngine->Topic_AddTopic($oTopic); diff --git a/tests/fixtures/UserFixtures.php b/tests/fixtures/UserFixtures.php index ad510383..c8547e89 100644 --- a/tests/fixtures/UserFixtures.php +++ b/tests/fixtures/UserFixtures.php @@ -12,25 +12,50 @@ class UserFixtures extends AbstractFixtures public function load() { - $oUserGolfer = Engine::GetEntity('User'); - $oUserGolfer->setLogin('golfer'); - $oUserGolfer->setPassword(md5('qwerty')); - $oUserGolfer->setMail('golfer@gmail.com'); + $oUserFirst = $this->_createUser('user_first', 'qwerty','user_first@info.com', '2012-11-1 00:10:20'); + $this->addReference('user-first', $oUserFirst); - $oUserGolfer->setUserDateRegister(date("Y-m-d H:i:s")); // @todo freeze - $oUserGolfer->setUserIpRegister('127.0.0.1'); - $oUserGolfer->setUserActivate('1'); - $oUserGolfer->setUserActivateKey('0'); + $oUserSecond = $this->_createUser('user_second', 'qwerty','user_second@info.com', '2012-11-1 00:20:50'); + $this->addReference('user-second', $oUserSecond); - $this->oEngine->User_Add($oUserGolfer); + $oUserThird = $this->_createUser('user_third', 'qwerty','user_third@info.com', '2012-11-2 09:20:50'); + $this->addReference('user-third', $oUserThird); - $oUserGolfer->setProfileName('Sergey Doryba'); - $oUserGolfer->setProfileAbout('... Sergey Doryba profile description'); - $oUserGolfer->setProfileSex('man'); + $oUserFirst->getId(); + $oUserFirst->setProfileName('UserFirst FullName'); + $oUserFirst->setProfileAbout('... UserFirst profile description'); + $oUserFirst->setProfileSex('man'); + + $this->oEngine->User_Update($oUserFirst); + $this->addReference('user-first', $oUserFirst); - $this->oEngine->User_Update($oUserGolfer); - $this->addReference('user-golfer', $oUserGolfer); } -} + /** + * Create user with default values + * + * @param string $sUserName + * @param string $sPassword + * @param string $sMail + * @param string $sDate + * + * @return ModuleTopic_EntityUser + */ + private function _createUser($sUserName, $sPassword,$sMail,$sDate) + { + $oUser = Engine::GetEntity('User'); + /* @var $oUser ModuleTopic_EntityUser */ + $oUser->setLogin($sUserName); + $oUser->setPassword(md5($sPassword)); + $oUser->setMail($sMail); + $oUser->setUserDateRegister($sDate); + $oUser->setUserIpRegister('127.0.0.1'); + $oUser->setUserActivate('1'); + $oUser->setUserActivateKey('0'); + $this->oEngine->User_Add($oUser); + + return $oUser; + } + +} \ No newline at end of file diff --git a/tests/fixtures/sql/insert.sql b/tests/fixtures/sql/insert.sql new file mode 100644 index 00000000..f46c69f8 --- /dev/null +++ b/tests/fixtures/sql/insert.sql @@ -0,0 +1,45 @@ +-- -------------------------------------------------------- + +-- +-- Дамп данных таблицы `prefix_user` +-- + +INSERT INTO `prefix_user` (`user_id`, `user_login`, `user_password`, `user_mail`, `user_skill`, `user_date_register`, `user_date_activate`, `user_date_comment_last`, `user_ip_register`, `user_rating`, `user_count_vote`, `user_activate`, `user_activate_key`, `user_profile_name`, `user_profile_sex`, `user_profile_country`, `user_profile_region`, `user_profile_city`, `user_profile_birthday`, `user_profile_about`, `user_profile_date`, `user_profile_avatar`, `user_profile_foto`, `user_settings_notice_new_topic`, `user_settings_notice_new_comment`, `user_settings_notice_new_talk`, `user_settings_notice_reply_comment`, `user_settings_notice_new_friend`, `user_settings_timezone`) VALUES +(1, 'admin', 'd8578edf8458ce06fbc5bb76a58c5ca4', 'admin@admin.adm', 0.000, '2012-10-1 00:00:00', NULL, NULL, '127.0.0.1', 0.000, 0, 1, NULL, NULL, 'other', NULL, NULL, NULL, NULL, NULL, NULL, '0', NULL, 1, 1, 1, 1, 1, NULL); + +-- -------------------------------------------------------- + + +-- +-- Дамп данных таблицы `prefix_user_administrator` +-- + +INSERT INTO `prefix_user_administrator` (`user_id`) VALUES +(1); + +-- -------------------------------------------------------- + + +-- +-- Дамп данных таблицы `prefix_user_field` +-- + +INSERT INTO `prefix_user_field` (`id`, `type`, `name`, `title`, `pattern`) VALUES +(1, 'contact', 'phone', 'Телефон', ''), +(2, 'contact', 'mail', 'E-mail', '{*}'), +(3, 'contact', 'skype', 'Skype', '{*}'), +(4, 'contact', 'icq', 'ICQ', '{*}'), +(5, 'contact', 'www', 'Сайт', '{*}'), +(6, 'social', 'twitter', 'Twitter', '{*}'), +(7, 'social', 'facebook', 'Facebook', '{*}'), +(8, 'social', 'vkontakte', 'ВКонтакте', '{*}'), +(9, 'social', 'odnoklassniki', 'Одноклассники', '{*}'); + +-- -------------------------------------------------------- + +-- +-- Дамп данных таблицы `prefix_blog` +-- + +INSERT INTO `prefix_blog` (`blog_id`, `user_owner_id`, `blog_title`, `blog_description`, `blog_type`, `blog_date_add`, `blog_date_edit`, `blog_rating`, `blog_count_vote`, `blog_count_user`, `blog_count_topic`, `blog_limit_rating_topic`, `blog_url`, `blog_avatar`) VALUES +(1, 1, 'Blog by admin', 'This is Admin personal blog.', 'personal', '2012-11-07 09:20:00', NULL, 0.000, 0, 0, 0, -1000.000, NULL, '0'); diff --git a/tests/fixtures/sql/install_base.sql b/tests/fixtures/sql/install_base.sql new file mode 100644 index 00000000..7b7e9c9c --- /dev/null +++ b/tests/fixtures/sql/install_base.sql @@ -0,0 +1,991 @@ +-- +-- Database LiveStreet version 1.0.1 +-- + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_blog` +-- + +CREATE TABLE IF NOT EXISTS `prefix_blog` ( + `blog_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `user_owner_id` int(11) unsigned NOT NULL, + `blog_title` varchar(200) NOT NULL, + `blog_description` text NOT NULL, + `blog_type` enum('personal','open','invite','close') DEFAULT 'personal', + `blog_date_add` datetime NOT NULL, + `blog_date_edit` datetime DEFAULT NULL, + `blog_rating` float(9,3) NOT NULL DEFAULT '0.000', + `blog_count_vote` int(11) unsigned NOT NULL DEFAULT '0', + `blog_count_user` int(11) unsigned NOT NULL DEFAULT '0', + `blog_count_topic` int(10) unsigned NOT NULL DEFAULT '0', + `blog_limit_rating_topic` float(9,3) NOT NULL DEFAULT '0.000', + `blog_url` varchar(200) DEFAULT NULL, + `blog_avatar` varchar(250) DEFAULT NULL, + PRIMARY KEY (`blog_id`), + KEY `user_owner_id` (`user_owner_id`), + KEY `blog_type` (`blog_type`), + KEY `blog_url` (`blog_url`), + KEY `blog_title` (`blog_title`), + KEY `blog_count_topic` (`blog_count_topic`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; + + +-- +-- Структура таблицы `prefix_blog_user` +-- + +CREATE TABLE IF NOT EXISTS `prefix_blog_user` ( + `blog_id` int(11) unsigned NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `user_role` int(3) DEFAULT '1', + UNIQUE KEY `blog_id_user_id_uniq` (`blog_id`,`user_id`), + KEY `blog_id` (`blog_id`), + KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_blog_user` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_comment` +-- + +CREATE TABLE IF NOT EXISTS `prefix_comment` ( + `comment_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `comment_pid` int(11) unsigned DEFAULT NULL, + `comment_left` int(11) NOT NULL DEFAULT '0', + `comment_right` int(11) NOT NULL DEFAULT '0', + `comment_level` int(11) NOT NULL DEFAULT '0', + `target_id` int(11) unsigned DEFAULT NULL, + `target_type` enum('topic','talk') NOT NULL DEFAULT 'topic', + `target_parent_id` int(11) NOT NULL DEFAULT '0', + `user_id` int(11) unsigned NOT NULL, + `comment_text` text NOT NULL, + `comment_text_hash` varchar(32) NOT NULL, + `comment_date` datetime NOT NULL, + `comment_user_ip` varchar(20) NOT NULL, + `comment_rating` float(9,3) NOT NULL DEFAULT '0.000', + `comment_count_vote` int(11) unsigned NOT NULL DEFAULT '0', + `comment_count_favourite` int(11) unsigned NOT NULL DEFAULT '0', + `comment_delete` tinyint(4) NOT NULL DEFAULT '0', + `comment_publish` tinyint(1) NOT NULL DEFAULT '1', + PRIMARY KEY (`comment_id`), + KEY `comment_pid` (`comment_pid`), + KEY `type_date_rating` (`target_type`,`comment_date`,`comment_rating`), + KEY `id_type` (`target_id`,`target_type`), + KEY `type_delete_publish` (`target_type`,`comment_delete`,`comment_publish`), + KEY `user_type` (`user_id`,`target_type`), + KEY `target_parent_id` (`target_parent_id`), + KEY `comment_left` (`comment_left`), + KEY `comment_right` (`comment_right`), + KEY `comment_level` (`comment_level`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_comment` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_comment_online` +-- + +CREATE TABLE IF NOT EXISTS `prefix_comment_online` ( + `comment_online_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `target_id` int(11) unsigned DEFAULT NULL, + `target_type` enum('topic','talk') NOT NULL DEFAULT 'topic', + `target_parent_id` int(11) NOT NULL DEFAULT '0', + `comment_id` int(11) unsigned NOT NULL, + PRIMARY KEY (`comment_online_id`), + UNIQUE KEY `id_type` (`target_id`,`target_type`), + KEY `comment_id` (`comment_id`), + KEY `type_parent` (`target_type`,`target_parent_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_comment_online` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_favourite` +-- + +CREATE TABLE IF NOT EXISTS `prefix_favourite` ( + `user_id` int(11) unsigned NOT NULL, + `target_id` int(11) unsigned DEFAULT NULL, + `target_type` enum('topic','comment','talk') DEFAULT 'topic', + `target_publish` tinyint(1) DEFAULT '1', + `tags` varchar(250) NOT NULL, + UNIQUE KEY `user_id_target_id_type` (`user_id`,`target_id`,`target_type`), + KEY `target_publish` (`target_publish`), + KEY `id_type` (`target_id`,`target_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_favourite` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_favourite_tag` +-- + +CREATE TABLE IF NOT EXISTS `prefix_favourite_tag` ( + `user_id` int(10) unsigned NOT NULL, + `target_id` int(11) NOT NULL, + `target_type` enum('topic','comment','talk') NOT NULL, + `is_user` tinyint(1) NOT NULL DEFAULT '0', + `text` varchar(50) NOT NULL, + KEY `user_id_target_type_id` (`user_id`,`target_type`,`target_id`), + KEY `target_type_id` (`target_type`,`target_id`), + KEY `is_user` (`is_user`), + KEY `text` (`text`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_favourite_tag` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_friend` +-- + +CREATE TABLE IF NOT EXISTS `prefix_friend` ( + `user_from` int(11) unsigned NOT NULL DEFAULT '0', + `user_to` int(11) unsigned NOT NULL DEFAULT '0', + `status_from` int(4) NOT NULL, + `status_to` int(4) NOT NULL, + PRIMARY KEY (`user_from`,`user_to`), + KEY `user_to` (`user_to`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_friend` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_invite` +-- + +CREATE TABLE IF NOT EXISTS `prefix_invite` ( + `invite_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `invite_code` varchar(32) NOT NULL, + `user_from_id` int(11) unsigned NOT NULL, + `user_to_id` int(11) unsigned DEFAULT NULL, + `invite_date_add` datetime NOT NULL, + `invite_date_used` datetime DEFAULT NULL, + `invite_used` tinyint(1) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`invite_id`), + UNIQUE KEY `invite_code` (`invite_code`), + KEY `user_from_id` (`user_from_id`), + KEY `user_to_id` (`user_to_id`), + KEY `invite_date_add` (`invite_date_add`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_invite` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_notify_task` +-- + +CREATE TABLE IF NOT EXISTS `prefix_notify_task` ( + `notify_task_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_login` varchar(30) DEFAULT NULL, + `user_mail` varchar(50) DEFAULT NULL, + `notify_subject` varchar(200) DEFAULT NULL, + `notify_text` text, + `date_created` datetime DEFAULT NULL, + `notify_task_status` tinyint(2) unsigned DEFAULT NULL, + PRIMARY KEY (`notify_task_id`), + KEY `date_created` (`date_created`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_notify_task` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_reminder` +-- + +CREATE TABLE IF NOT EXISTS `prefix_reminder` ( + `reminder_code` varchar(32) NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `reminder_date_add` datetime NOT NULL, + `reminder_date_used` datetime DEFAULT '0000-00-00 00:00:00', + `reminder_date_expire` datetime NOT NULL, + `reminde_is_used` tinyint(1) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`reminder_code`), + UNIQUE KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_reminder` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_session` +-- + +CREATE TABLE IF NOT EXISTS `prefix_session` ( + `session_key` varchar(32) NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `session_ip_create` varchar(15) NOT NULL, + `session_ip_last` varchar(15) NOT NULL, + `session_date_create` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `session_date_last` datetime NOT NULL, + PRIMARY KEY (`session_key`), + UNIQUE KEY `user_id` (`user_id`), + KEY `session_date_last` (`session_date_last`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_session` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_stream_event` +-- + +CREATE TABLE IF NOT EXISTS `prefix_stream_event` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `event_type` varchar(100) NOT NULL, + `target_id` int(11) NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `publish` tinyint(1) NOT NULL DEFAULT '1', + PRIMARY KEY (`id`), + KEY `event_type` (`event_type`,`user_id`), + KEY `user_id` (`user_id`), + KEY `publish` (`publish`), + KEY `target_id` (`target_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_stream_event` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_stream_subscribe` +-- + +CREATE TABLE IF NOT EXISTS `prefix_stream_subscribe` ( + `user_id` int(11) unsigned NOT NULL, + `target_user_id` int(11) NOT NULL, + KEY `user_id` (`user_id`,`target_user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_stream_subscribe` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_stream_user_type` +-- + +CREATE TABLE IF NOT EXISTS `prefix_stream_user_type` ( + `user_id` int(11) unsigned NOT NULL, + `event_type` varchar(100) DEFAULT NULL, + KEY `user_id` (`user_id`,`event_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_stream_user_type` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_subscribe` +-- + +CREATE TABLE IF NOT EXISTS `prefix_subscribe` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `target_type` varchar(20) NOT NULL, + `target_id` int(11) DEFAULT NULL, + `mail` varchar(50) NOT NULL, + `date_add` datetime NOT NULL, + `date_remove` datetime DEFAULT NULL, + `ip` varchar(20) NOT NULL, + `key` varchar(32) DEFAULT NULL, + `status` tinyint(1) NOT NULL DEFAULT '1', + PRIMARY KEY (`id`), + KEY `type` (`target_type`), + KEY `mail` (`mail`), + KEY `status` (`status`), + KEY `key` (`key`), + KEY `target_id` (`target_id`), + KEY `ip` (`ip`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_subscribe` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_talk` +-- + +CREATE TABLE IF NOT EXISTS `prefix_talk` ( + `talk_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(11) unsigned NOT NULL, + `talk_title` varchar(200) NOT NULL, + `talk_text` text NOT NULL, + `talk_date` datetime NOT NULL, + `talk_date_last` datetime NOT NULL, + `talk_user_id_last` int(11) NOT NULL, + `talk_user_ip` varchar(20) NOT NULL, + `talk_comment_id_last` int(11) DEFAULT NULL, + `talk_count_comment` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`talk_id`), + KEY `user_id` (`user_id`), + KEY `talk_title` (`talk_title`), + KEY `talk_date` (`talk_date`), + KEY `talk_date_last` (`talk_date_last`), + KEY `talk_user_id_last` (`talk_user_id_last`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_talk` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_talk_blacklist` +-- + +CREATE TABLE IF NOT EXISTS `prefix_talk_blacklist` ( + `user_id` int(10) unsigned NOT NULL, + `user_target_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`user_id`,`user_target_id`), + KEY `prefix_talk_blacklist_fk_target` (`user_target_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_talk_blacklist` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_talk_user` +-- + +CREATE TABLE IF NOT EXISTS `prefix_talk_user` ( + `talk_id` int(11) unsigned NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `date_last` datetime DEFAULT NULL, + `comment_id_last` int(11) NOT NULL DEFAULT '0', + `comment_count_new` int(11) NOT NULL DEFAULT '0', + `talk_user_active` tinyint(1) DEFAULT '1', + UNIQUE KEY `talk_id_user_id` (`talk_id`,`user_id`), + KEY `user_id` (`user_id`), + KEY `date_last` (`date_last`), + KEY `date_last_2` (`date_last`), + KEY `talk_user_active` (`talk_user_active`), + KEY `comment_count_new` (`comment_count_new`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_talk_user` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_topic` +-- + +CREATE TABLE IF NOT EXISTS `prefix_topic` ( + `topic_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `blog_id` int(11) unsigned NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `topic_type` enum('topic','link','question','photoset') NOT NULL DEFAULT 'topic', + `topic_title` varchar(200) NOT NULL, + `topic_tags` varchar(250) NOT NULL COMMENT 'tags separated by a comma', + `topic_date_add` datetime NOT NULL, + `topic_date_edit` datetime DEFAULT NULL, + `topic_user_ip` varchar(20) NOT NULL, + `topic_publish` tinyint(1) NOT NULL DEFAULT '0', + `topic_publish_draft` tinyint(1) NOT NULL DEFAULT '1', + `topic_publish_index` tinyint(1) NOT NULL DEFAULT '0', + `topic_rating` float(9,3) NOT NULL DEFAULT '0.000', + `topic_count_vote` int(11) unsigned NOT NULL DEFAULT '0', + `topic_count_vote_up` int(11) NOT NULL DEFAULT '0', + `topic_count_vote_down` int(11) NOT NULL DEFAULT '0', + `topic_count_vote_abstain` int(11) NOT NULL DEFAULT '0', + `topic_count_read` int(11) unsigned NOT NULL DEFAULT '0', + `topic_count_comment` int(11) unsigned NOT NULL DEFAULT '0', + `topic_count_favourite` int(11) unsigned NOT NULL DEFAULT '0', + `topic_cut_text` varchar(100) DEFAULT NULL, + `topic_forbid_comment` tinyint(1) NOT NULL DEFAULT '0', + `topic_text_hash` varchar(32) NOT NULL, + PRIMARY KEY (`topic_id`), + KEY `blog_id` (`blog_id`), + KEY `user_id` (`user_id`), + KEY `topic_date_add` (`topic_date_add`), + KEY `topic_rating` (`topic_rating`), + KEY `topic_publish` (`topic_publish`), + KEY `topic_text_hash` (`topic_text_hash`), + KEY `topic_count_comment` (`topic_count_comment`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_topic` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_topic_content` +-- + +CREATE TABLE IF NOT EXISTS `prefix_topic_content` ( + `topic_id` int(11) unsigned NOT NULL, + `topic_text` longtext NOT NULL, + `topic_text_short` text NOT NULL, + `topic_text_source` longtext NOT NULL, + `topic_extra` text NOT NULL, + PRIMARY KEY (`topic_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_topic_content` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_topic_photo` +-- + +CREATE TABLE IF NOT EXISTS `prefix_topic_photo` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `topic_id` int(11) unsigned DEFAULT NULL, + `path` varchar(255) NOT NULL, + `description` text, + `target_tmp` varchar(40) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `topic_id` (`topic_id`), + KEY `target_tmp` (`target_tmp`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_topic_photo` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_topic_question_vote` +-- + +CREATE TABLE IF NOT EXISTS `prefix_topic_question_vote` ( + `topic_id` int(11) unsigned NOT NULL, + `user_voter_id` int(11) unsigned NOT NULL, + `answer` tinyint(4) NOT NULL, + UNIQUE KEY `topic_id_user_id` (`topic_id`,`user_voter_id`), + KEY `user_voter_id` (`user_voter_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_topic_question_vote` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_topic_read` +-- + +CREATE TABLE IF NOT EXISTS `prefix_topic_read` ( + `topic_id` int(11) unsigned NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `date_read` datetime NOT NULL, + `comment_count_last` int(10) unsigned NOT NULL DEFAULT '0', + `comment_id_last` int(11) NOT NULL DEFAULT '0', + UNIQUE KEY `topic_id_user_id` (`topic_id`,`user_id`), + KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_topic_read` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_topic_tag` +-- + +CREATE TABLE IF NOT EXISTS `prefix_topic_tag` ( + `topic_tag_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `topic_id` int(11) unsigned NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `blog_id` int(11) unsigned NOT NULL, + `topic_tag_text` varchar(50) NOT NULL, + PRIMARY KEY (`topic_tag_id`), + KEY `topic_id` (`topic_id`), + KEY `user_id` (`user_id`), + KEY `blog_id` (`blog_id`), + KEY `topic_tag_text` (`topic_tag_text`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_topic_tag` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_user` +-- + +CREATE TABLE IF NOT EXISTS `prefix_user` ( + `user_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `user_login` varchar(30) NOT NULL, + `user_password` varchar(50) NOT NULL, + `user_mail` varchar(50) NOT NULL, + `user_skill` float(9,3) unsigned NOT NULL DEFAULT '0.000', + `user_date_register` datetime NOT NULL, + `user_date_activate` datetime DEFAULT NULL, + `user_date_comment_last` datetime DEFAULT NULL, + `user_ip_register` varchar(20) NOT NULL, + `user_rating` float(9,3) NOT NULL DEFAULT '0.000', + `user_count_vote` int(11) unsigned NOT NULL DEFAULT '0', + `user_activate` tinyint(1) unsigned NOT NULL DEFAULT '0', + `user_activate_key` varchar(32) DEFAULT NULL, + `user_profile_name` varchar(50) DEFAULT NULL, + `user_profile_sex` enum('man','woman','other') NOT NULL DEFAULT 'other', + `user_profile_country` varchar(30) DEFAULT NULL, + `user_profile_region` varchar(30) DEFAULT NULL, + `user_profile_city` varchar(30) DEFAULT NULL, + `user_profile_birthday` datetime DEFAULT NULL, + `user_profile_about` text, + `user_profile_date` datetime DEFAULT NULL, + `user_profile_avatar` varchar(250) DEFAULT NULL, + `user_profile_foto` varchar(250) DEFAULT NULL, + `user_settings_notice_new_topic` tinyint(1) NOT NULL DEFAULT '1', + `user_settings_notice_new_comment` tinyint(1) NOT NULL DEFAULT '1', + `user_settings_notice_new_talk` tinyint(1) NOT NULL DEFAULT '1', + `user_settings_notice_reply_comment` tinyint(1) NOT NULL DEFAULT '1', + `user_settings_notice_new_friend` tinyint(1) NOT NULL DEFAULT '1', + `user_settings_timezone` varchar(6) DEFAULT NULL, + PRIMARY KEY (`user_id`), + UNIQUE KEY `user_login` (`user_login`), + UNIQUE KEY `user_mail` (`user_mail`), + KEY `user_activate_key` (`user_activate_key`), + KEY `user_activate` (`user_activate`), + KEY `user_rating` (`user_rating`), + KEY `user_profile_sex` (`user_profile_sex`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; + + +-- +-- Структура таблицы `prefix_userfeed_subscribe` +-- + +CREATE TABLE IF NOT EXISTS `prefix_userfeed_subscribe` ( + `user_id` int(11) unsigned NOT NULL, + `subscribe_type` tinyint(4) NOT NULL, + `target_id` int(11) NOT NULL, + KEY `user_id` (`user_id`,`subscribe_type`,`target_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_userfeed_subscribe` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_user_administrator` +-- + +CREATE TABLE IF NOT EXISTS `prefix_user_administrator` ( + `user_id` int(11) unsigned NOT NULL, + UNIQUE KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +-- +-- Структура таблицы `prefix_user_changemail` +-- + +CREATE TABLE IF NOT EXISTS `prefix_user_changemail` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) unsigned NOT NULL, + `date_add` datetime NOT NULL, + `date_used` datetime DEFAULT NULL, + `date_expired` datetime NOT NULL, + `mail_from` varchar(50) NOT NULL, + `mail_to` varchar(50) NOT NULL, + `code_from` varchar(32) NOT NULL, + `code_to` varchar(32) NOT NULL, + `confirm_from` tinyint(1) NOT NULL DEFAULT '0', + `confirm_to` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + KEY `code_from` (`code_from`), + KEY `code_to` (`code_to`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_user_changemail` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_user_field` +-- + +CREATE TABLE IF NOT EXISTS `prefix_user_field` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `type` varchar(50) NOT NULL, + `name` varchar(255) NOT NULL, + `title` varchar(255) NOT NULL, + `pattern` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `name` (`name`), + KEY `type` (`type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ; + + +-- +-- Структура таблицы `prefix_user_field_value` +-- + +CREATE TABLE IF NOT EXISTS `prefix_user_field_value` ( + `user_id` int(11) unsigned NOT NULL, + `field_id` int(11) DEFAULT NULL, + `value` varchar(255) DEFAULT NULL, + KEY `user_id` (`user_id`,`field_id`), + KEY `field_id` (`field_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_user_field_value` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_user_note` +-- + +CREATE TABLE IF NOT EXISTS `prefix_user_note` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `target_user_id` int(11) unsigned NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `text` text NOT NULL, + `date_add` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + KEY `target_user_id` (`target_user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_user_note` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_vote` +-- + +CREATE TABLE IF NOT EXISTS `prefix_vote` ( + `target_id` int(11) unsigned NOT NULL DEFAULT '0', + `target_type` enum('topic','blog','user','comment') NOT NULL DEFAULT 'topic', + `user_voter_id` int(11) unsigned NOT NULL, + `vote_direction` tinyint(2) DEFAULT '0', + `vote_value` float(9,3) NOT NULL DEFAULT '0.000', + `vote_date` datetime NOT NULL, + `vote_ip` varchar(15) NOT NULL DEFAULT '', + PRIMARY KEY (`target_id`,`target_type`,`user_voter_id`), + KEY `user_voter_id` (`user_voter_id`), + KEY `vote_ip` (`vote_ip`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп данных таблицы `prefix_vote` +-- + + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `prefix_wall` +-- + +CREATE TABLE IF NOT EXISTS `prefix_wall` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `pid` int(11) DEFAULT NULL, + `wall_user_id` int(11) unsigned NOT NULL, + `user_id` int(11) unsigned NOT NULL, + `count_reply` int(11) NOT NULL DEFAULT '0', + `last_reply` varchar(100) NOT NULL, + `date_add` datetime NOT NULL, + `ip` varchar(20) NOT NULL, + `text` text NOT NULL, + PRIMARY KEY (`id`), + KEY `pid` (`pid`), + KEY `wall_user_id` (`wall_user_id`), + KEY `ip` (`ip`), + KEY `user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Дамп данных таблицы `prefix_wall` +-- + + +-- +-- Ограничения внешнего ключа сохраненных таблиц +-- + +-- +-- Ограничения внешнего ключа таблицы `prefix_blog` +-- +ALTER TABLE `prefix_blog` + ADD CONSTRAINT `prefix_blog_fk` FOREIGN KEY (`user_owner_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_blog_user` +-- +ALTER TABLE `prefix_blog_user` + ADD CONSTRAINT `prefix_blog_user_fk` FOREIGN KEY (`blog_id`) REFERENCES `prefix_blog` (`blog_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_blog_user_fk1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_comment` +-- +ALTER TABLE `prefix_comment` + ADD CONSTRAINT `prefix_topic_comment_fk` FOREIGN KEY (`comment_pid`) REFERENCES `prefix_comment` (`comment_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `topic_comment_fk1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_comment_online` +-- +ALTER TABLE `prefix_comment_online` + ADD CONSTRAINT `prefix_topic_comment_online_fk1` FOREIGN KEY (`comment_id`) REFERENCES `prefix_comment` (`comment_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_favourite` +-- +ALTER TABLE `prefix_favourite` + ADD CONSTRAINT `prefix_favourite_target_fk` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_favourite_tag` +-- +ALTER TABLE `prefix_favourite_tag` + ADD CONSTRAINT `prefix_favourite_tag_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_friend` +-- +ALTER TABLE `prefix_friend` + ADD CONSTRAINT `prefix_friend_from_fk` FOREIGN KEY (`user_from`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_friend_to_fk` FOREIGN KEY (`user_to`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_invite` +-- +ALTER TABLE `prefix_invite` + ADD CONSTRAINT `prefix_invite_fk` FOREIGN KEY (`user_from_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_invite_fk1` FOREIGN KEY (`user_to_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_reminder` +-- +ALTER TABLE `prefix_reminder` + ADD CONSTRAINT `prefix_reminder_fk` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_session` +-- +ALTER TABLE `prefix_session` + ADD CONSTRAINT `prefix_session_fk` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_stream_event` +-- +ALTER TABLE `prefix_stream_event` + ADD CONSTRAINT `prefix_stream_event_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_stream_subscribe` +-- +ALTER TABLE `prefix_stream_subscribe` + ADD CONSTRAINT `prefix_stream_subscribe_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_stream_user_type` +-- +ALTER TABLE `prefix_stream_user_type` + ADD CONSTRAINT `prefix_stream_user_type_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_talk` +-- +ALTER TABLE `prefix_talk` + ADD CONSTRAINT `prefix_talk_fk` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_talk_blacklist` +-- +ALTER TABLE `prefix_talk_blacklist` + ADD CONSTRAINT `prefix_talk_blacklist_fk_target` FOREIGN KEY (`user_target_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_talk_blacklist_fk_user` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_talk_user` +-- +ALTER TABLE `prefix_talk_user` + ADD CONSTRAINT `prefix_talk_user_fk` FOREIGN KEY (`talk_id`) REFERENCES `prefix_talk` (`talk_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_talk_user_fk1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_topic` +-- +ALTER TABLE `prefix_topic` + ADD CONSTRAINT `prefix_topic_fk` FOREIGN KEY (`blog_id`) REFERENCES `prefix_blog` (`blog_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_topic_fk1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_topic_content` +-- +ALTER TABLE `prefix_topic_content` + ADD CONSTRAINT `prefix_topic_content_fk` FOREIGN KEY (`topic_id`) REFERENCES `prefix_topic` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_topic_photo` +-- +ALTER TABLE `prefix_topic_photo` + ADD CONSTRAINT `prefix_topic_photo_ibfk_1` FOREIGN KEY (`topic_id`) REFERENCES `prefix_topic` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_topic_question_vote` +-- +ALTER TABLE `prefix_topic_question_vote` + ADD CONSTRAINT `prefix_topic_question_vote_fk` FOREIGN KEY (`topic_id`) REFERENCES `prefix_topic` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_topic_question_vote_fk1` FOREIGN KEY (`user_voter_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_topic_read` +-- +ALTER TABLE `prefix_topic_read` + ADD CONSTRAINT `prefix_topic_read_fk` FOREIGN KEY (`topic_id`) REFERENCES `prefix_topic` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_topic_read_fk1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_topic_tag` +-- +ALTER TABLE `prefix_topic_tag` + ADD CONSTRAINT `prefix_topic_tag_fk` FOREIGN KEY (`topic_id`) REFERENCES `prefix_topic` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_topic_tag_fk1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_topic_tag_fk2` FOREIGN KEY (`blog_id`) REFERENCES `prefix_blog` (`blog_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_userfeed_subscribe` +-- +ALTER TABLE `prefix_userfeed_subscribe` + ADD CONSTRAINT `prefix_userfeed_subscribe_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_user_administrator` +-- +ALTER TABLE `prefix_user_administrator` + ADD CONSTRAINT `user_administrator_fk` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_user_changemail` +-- +ALTER TABLE `prefix_user_changemail` + ADD CONSTRAINT `prefix_user_changemail_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_user_field_value` +-- +ALTER TABLE `prefix_user_field_value` + ADD CONSTRAINT `prefix_user_field_value_ibfk_2` FOREIGN KEY (`field_id`) REFERENCES `prefix_user_field` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_user_field_value_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_user_note` +-- +ALTER TABLE `prefix_user_note` + ADD CONSTRAINT `prefix_user_note_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_user_note_ibfk_1` FOREIGN KEY (`target_user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_vote` +-- +ALTER TABLE `prefix_vote` + ADD CONSTRAINT `prefix_topic_vote_fk1` FOREIGN KEY (`user_voter_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Ограничения внешнего ключа таблицы `prefix_wall` +-- +ALTER TABLE `prefix_wall` + ADD CONSTRAINT `prefix_wall_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `prefix_wall_ibfk_1` FOREIGN KEY (`wall_user_id`) REFERENCES `prefix_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;