752 lines
28 KiB
PHP
752 lines
28 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class DatabaseModel extends CI_Model
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->createMissingDatabases();
|
|
}
|
|
|
|
public function createMissingDatabases()
|
|
{
|
|
//$this->createDatabases();
|
|
// TODO: Update data base generation
|
|
// $this->createTables();
|
|
//$this->addIndices();
|
|
//$this->addAutoIncrements();
|
|
//$this->addConstraints();
|
|
|
|
//$this->fillBlogTables();
|
|
//$this->fillFeedbackTable();
|
|
//$this->fillMainTable();
|
|
//$this->fillProjectsTable();
|
|
}
|
|
|
|
private function createDatabases()
|
|
{
|
|
// $this->db->query('CREATE DATABASE IF NOT EXISTS `blog` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci');
|
|
// $this->db->query('CREATE DATABASE IF NOT EXISTS `kingofdog` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci');
|
|
// $this->db->query('CREATE DATABASE IF NOT EXISTS `portfolio` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci');
|
|
// $this->db->query('CREATE DATABASE IF NOT EXISTS `social_media` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci');
|
|
$this->db->query('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 utf8mb4 */;');
|
|
}
|
|
|
|
private function createTables()
|
|
{
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `blog_categories` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(25) NOT NULL,
|
|
`display_name` varchar(50) NOT NULL,
|
|
PRIMARY KEY (`ID`),
|
|
UNIQUE KEY `blog_categories_name_display_name_uindex` (`name`, `display_name`)
|
|
) ENGINE = InnoDB DEFAULT CHARSET = latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `blog_comments` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`post_id` int(11) NOT NULL,
|
|
`user_id` int(11) NOT NULL,
|
|
`comment` text NOT NULL,
|
|
`date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`like_count` int(11) NOT NULL,
|
|
`reply` tinyint(1) NOT NULL DEFAULT '0',
|
|
`replyTo_id` int(11) DEFAULT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `blog_content` (
|
|
`contentID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`postID` int(11) NOT NULL,
|
|
`contentDate` datetime NOT NULL,
|
|
`content` mediumtext COLLATE utf8mb4_bin NOT NULL,
|
|
`contentAuthorID` int(11) DEFAULT NULL,
|
|
`isNativePost` tinyint(1) NOT NULL,
|
|
`isActive` tinyint(1) NOT NULL,
|
|
`versionMessage` varchar(300) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
|
`language` varchar(10) CHARACTER SET latin1 DEFAULT NULL,
|
|
`wordCount` int(11) NOT NULL DEFAULT '0',
|
|
PRIMARY KEY (`contentID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `blog_posts` (
|
|
`postID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`postUrl` varchar(300) CHARACTER SET latin1 DEFAULT NULL,
|
|
`postPublishDate` datetime DEFAULT NULL,
|
|
`postLastEdit` datetime DEFAULT NULL,
|
|
`postAuthorID` int(11) DEFAULT NULL,
|
|
`postImage` text CHARACTER SET latin1,
|
|
`postState` varchar(50) CHARACTER SET latin1 NOT NULL,
|
|
`postViews` int(11) NOT NULL DEFAULT '0',
|
|
`postCategoryID` int(11) NOT NULL,
|
|
`postIsDeleted` tinyint(1) NOT NULL DEFAULT '0',
|
|
`postDeletedDate` datetime DEFAULT NULL,
|
|
PRIMARY KEY (`postID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `blog_post_likes` (
|
|
`post_id` int(11) NOT NULL,
|
|
`user_id` int(11) NOT NULL,
|
|
PRIMARY KEY (`post_id`, `user_id`),
|
|
KEY `fk_post_likes_user` (`user_id`),
|
|
CONSTRAINT `fk_post_likes_post` FOREIGN KEY (`post_id`) REFERENCES `blog_posts` (`postID`),
|
|
CONSTRAINT `fk_post_likes_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `blog_post_tags` (
|
|
`post_id` int(11) NOT NULL,
|
|
`tag_id` int(11) NOT NULL,
|
|
PRIMARY KEY (`post_id`, `tag_id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `blog_states` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(15) NOT NULL,
|
|
`display_name` varchar(15) NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `blog_tags` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(25) NOT NULL,
|
|
`display_name` varchar(50) NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `blog_translations` (
|
|
`postTranslationID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`postID` int(11) NOT NULL,
|
|
`language` varchar(5) COLLATE utf8mb4_bin NOT NULL DEFAULT 'de',
|
|
`postTitle` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
|
|
`postDesc` text COLLATE utf8mb4_bin,
|
|
PRIMARY KEY (`postTranslationID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `calendar` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`title` varchar(300) NOT NULL,
|
|
`allDay` tinyint(1) NOT NULL,
|
|
`start` varchar(20) NOT NULL,
|
|
`end` varchar(20) NOT NULL,
|
|
`url` text NOT NULL,
|
|
`overlap` tinyint(1) NOT NULL,
|
|
`color` text NOT NULL,
|
|
`textColor` text NOT NULL,
|
|
`description` text NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `feedback` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`page` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
|
|
`message` text COLLATE utf8mb4_bin,
|
|
`datetime` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`anonymous` tinyint(1) DEFAULT '1',
|
|
`userID` int(11) DEFAULT NULL,
|
|
`email` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
|
|
`feedbackState` int(11) NOT NULL DEFAULT '0',
|
|
`lastStateUpdate` datetime DEFAULT NULL,
|
|
`feedbackStatusMessage` text COLLATE utf8mb4_bin,
|
|
`supporterID` int(11) DEFAULT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `feedback_archive` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`page` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
|
|
`message` text COLLATE utf8mb4_bin,
|
|
`datetime` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
`anonymous` tinyint(1) DEFAULT '1',
|
|
`userID` int(11) DEFAULT NULL,
|
|
`email` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
|
|
`feedbackState` int(11) NOT NULL DEFAULT '0',
|
|
`feedbackStatusMessage` text COLLATE utf8mb4_bin,
|
|
`supporterID` int(11) DEFAULT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `feedback_states` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(50) NOT NULL,
|
|
`displayname` text NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `files` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(50) NOT NULL,
|
|
`original_name` varchar(50) NOT NULL,
|
|
`type` varchar(30) NOT NULL,
|
|
`size` int(11) NOT NULL,
|
|
`path` varchar(300) NOT NULL,
|
|
`uploadDate` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `notifications` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`recipientID` int(11) NOT NULL,
|
|
`senderID` int(11) NOT NULL,
|
|
`unread` tinyint(1) NOT NULL,
|
|
`type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
`referenceID` int(11) NOT NULL,
|
|
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
`parameters` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `projects` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(255) CHARACTER SET latin1 DEFAULT NULL,
|
|
`datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`source` text CHARACTER SET latin1,
|
|
`isDownloadable` tinyint(1) NOT NULL DEFAULT '0',
|
|
`downloadLink` text COLLATE utf8mb4_bin,
|
|
`isOpenSource` tinyint(1) NOT NULL DEFAULT '0',
|
|
`openSourceLink` text COLLATE utf8mb4_bin,
|
|
`customLink` text COLLATE utf8mb4_bin,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `projects_categories` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`collection` text NOT NULL,
|
|
`displayname` text NOT NULL,
|
|
`displaynameEnglish` text NOT NULL,
|
|
`displaynameFrench` text NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `projects_entry_categories` (
|
|
`projectID` int(11) NOT NULL,
|
|
`categoryID` int(11) NOT NULL,
|
|
PRIMARY KEY (`projectID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `projects_entry_votes` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`projectID` int(11) NOT NULL,
|
|
`userID` int(11) NOT NULL,
|
|
`type` int(11) NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `projects_translations` (
|
|
`translationID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`projectID` int(11) NOT NULL,
|
|
`title` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`description` text COLLATE utf8mb4_unicode_ci,
|
|
`content` text COLLATE utf8mb4_unicode_ci,
|
|
`downloadName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`openSourceName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`customLinkName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`lang` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
PRIMARY KEY (`translationID`),
|
|
UNIQUE KEY `projectID` (`projectID`, `lang`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `redirects` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`redirect` text NOT NULL,
|
|
`url` text NOT NULL,
|
|
`temporary` tinyint(1) NOT NULL,
|
|
`expireDate` datetime DEFAULT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `social_posts` (
|
|
`post_id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`post_plattform` varchar(20) CHARACTER SET latin1 NOT NULL,
|
|
`post_content` text COLLATE utf8mb4_bin NOT NULL,
|
|
`post_url` varchar(75) CHARACTER SET latin1 NOT NULL,
|
|
`post_author` varchar(20) CHARACTER SET latin1 NOT NULL,
|
|
`post_author_url` text CHARACTER SET latin1 NOT NULL,
|
|
`post_date` int(11) NOT NULL,
|
|
`post_img_source` text CHARACTER SET latin1,
|
|
`post_original_id` bigint(20) NOT NULL,
|
|
PRIMARY KEY (`post_id`),
|
|
UNIQUE KEY `post_url` (`post_url`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `users` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`original_name` varchar(25) COLLATE utf8mb4_bin NOT NULL,
|
|
`username` varchar(25) COLLATE utf8mb4_bin NOT NULL,
|
|
`displayname` varchar(25) COLLATE utf8mb4_bin NOT NULL,
|
|
`login_method` int(11) DEFAULT '0',
|
|
`password` mediumtext COLLATE utf8mb4_bin,
|
|
`email` mediumtext COLLATE utf8mb4_bin NOT NULL,
|
|
`rank` mediumtext COLLATE utf8mb4_bin NOT NULL,
|
|
`profile_picture` mediumtext COLLATE utf8mb4_bin NOT NULL,
|
|
`header_image` mediumtext COLLATE utf8mb4_bin,
|
|
`social_networks` mediumtext COLLATE utf8mb4_bin,
|
|
`is_activated` tinyint(1) NOT NULL,
|
|
`activation_key` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,
|
|
`showAds` tinyint(1) NOT NULL DEFAULT '1',
|
|
`date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`isCurrentlyOnline` tinyint(1) DEFAULT '0',
|
|
`lastOnlineUpdate` datetime DEFAULT NULL,
|
|
`about` mediumtext COLLATE utf8mb4_bin NOT NULL,
|
|
`lastLogin` datetime NOT NULL,
|
|
`language` varchar(10) COLLATE utf8mb4_bin DEFAULT 'DE',
|
|
`country` varchar(2) COLLATE utf8mb4_bin DEFAULT NULL,
|
|
`gender` varchar(10) COLLATE utf8mb4_bin DEFAULT NULL,
|
|
`birthdate` mediumtext COLLATE utf8mb4_bin,
|
|
`birthyear` int(11) DEFAULT NULL,
|
|
`receiveEmails` tinyint(1) NOT NULL DEFAULT '1',
|
|
`receiveNewsletter` tinyint(1) NOT NULL DEFAULT '1',
|
|
`forget_password_key` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,
|
|
`isDeleted` tinyint(1) DEFAULT '0',
|
|
UNIQUE KEY `id` (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `users_history` (
|
|
`changeID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`changeDate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`ID` int(11) NOT NULL,
|
|
`username` varchar(25) NOT NULL,
|
|
`displayname` varchar(25) NOT NULL,
|
|
`email` text NOT NULL,
|
|
`rank` int(11) NOT NULL,
|
|
`profile_picture` text NOT NULL,
|
|
`header_image` text,
|
|
`social_networks` text,
|
|
`showAds` tinyint(1) NOT NULL DEFAULT '1',
|
|
`about` text NOT NULL,
|
|
`language` varchar(10) DEFAULT 'DE',
|
|
`country` varchar(2) DEFAULT NULL,
|
|
`gender` varchar(10) DEFAULT NULL,
|
|
`birthdate` text,
|
|
`birthyear` int(11) DEFAULT NULL,
|
|
`receiveEmails` tinyint(1) NOT NULL DEFAULT '1',
|
|
`receiveNewsletter` tinyint(1) NOT NULL DEFAULT '1',
|
|
UNIQUE KEY `changeID` (`changeID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `user_followers` (
|
|
`followedUserID` int(11) NOT NULL,
|
|
`followerUserID` int(11) NOT NULL,
|
|
`followedSince` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `user_posts` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`uuid` varchar(32) CHARACTER SET latin1 NOT NULL,
|
|
`user_id` int(11) DEFAULT NULL,
|
|
`content` text CHARACTER SET utf8 COLLATE utf8_bin,
|
|
`date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`lastEditDate` datetime DEFAULT NULL,
|
|
`reply_to` int(11) DEFAULT NULL,
|
|
PRIMARY KEY (`ID`),
|
|
UNIQUE KEY `user_posts_ID_uindex` (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `user_posts_hashtags` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`userID` int(11) NOT NULL,
|
|
`postID` int(11) NOT NULL,
|
|
`hashtag` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
`position` int(11) NOT NULL,
|
|
PRIMARY KEY (`ID`),
|
|
UNIQUE KEY `user_posts_hashtags_ID_uindex` (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `user_posts_likes` (
|
|
`postID` int(11) NOT NULL,
|
|
`likedUserID` int(11) NOT NULL,
|
|
`likerUserID` int(11) NOT NULL,
|
|
PRIMARY KEY (`postID`,`likerUserID`),
|
|
UNIQUE KEY `postID_2` (`postID`,`likerUserID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `user_posts_media` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`postID` int(11) NOT NULL,
|
|
`mediaType` varchar(50) NOT NULL,
|
|
`mediaUrl` text NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `user_posts_mentions` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`userID` int(11) NOT NULL,
|
|
`postID` int(11) NOT NULL,
|
|
`mentionedUserID` int(11) NOT NULL,
|
|
`position` int(11) NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
|
|
$this->db->query("CREATE TABLE IF NOT EXISTS `user_posts_reports` (
|
|
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
`postID` int(11) NOT NULL,
|
|
`reason` varchar(255) NOT NULL,
|
|
`reasonText` text NOT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
|
}
|
|
|
|
private function addIndices() {
|
|
|
|
$this->db->query("ALTER TABLE `blog_comments`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_content`
|
|
ADD PRIMARY KEY (`contentID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_posts`
|
|
ADD PRIMARY KEY (`postID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_post_likes`
|
|
ADD PRIMARY KEY (`post_id`,`user_id`),
|
|
ADD KEY `fk_post_likes_user` (`user_id`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_post_tags`
|
|
ADD PRIMARY KEY (`post_id`,`tag_id`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_states`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_tags`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_translations`
|
|
ADD PRIMARY KEY (`postTranslationID`);");
|
|
|
|
$this->db->query("ALTER TABLE `calendar`
|
|
ADD PRIMARY KEY (`id`);");
|
|
|
|
$this->db->query("ALTER TABLE `feedback`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `feedback_archive`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `feedback_states`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `files`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `notifications`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `projects`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `projects_categories`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `projects_entry_votes`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `projects_translations`
|
|
ADD PRIMARY KEY (`translationID`),
|
|
ADD UNIQUE KEY `projectID` (`projectID`,`lang`);");
|
|
|
|
$this->db->query("ALTER TABLE `redirects`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `social_posts`
|
|
ADD PRIMARY KEY (`post_id`),
|
|
ADD UNIQUE KEY `post_url` (`post_url`);");
|
|
|
|
$this->db->query("ALTER TABLE `users`
|
|
ADD UNIQUE KEY `id` (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `users_history`
|
|
ADD UNIQUE KEY `changeID` (`changeID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts`
|
|
ADD PRIMARY KEY (`ID`),
|
|
ADD UNIQUE KEY `user_posts_ID_uindex` (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_hashtags`
|
|
ADD PRIMARY KEY (`ID`),
|
|
ADD UNIQUE KEY `user_posts_hashtags_ID_uindex` (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_likes`
|
|
ADD PRIMARY KEY (`postID`,`likerUserID`),
|
|
ADD UNIQUE KEY `postID_2` (`postID`,`likerUserID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_media`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_mentions`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_reports`
|
|
ADD PRIMARY KEY (`ID`);");$this->db->query("ALTER TABLE `blog_categories`
|
|
ADD PRIMARY KEY (`ID`),
|
|
ADD UNIQUE KEY `blog_categories_name_display_name_uindex` (`name`,`display_name`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_comments`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_content`
|
|
ADD PRIMARY KEY (`contentID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_posts`
|
|
ADD PRIMARY KEY (`postID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_post_likes`
|
|
ADD PRIMARY KEY (`post_id`,`user_id`),
|
|
ADD KEY `fk_post_likes_user` (`user_id`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_post_tags`
|
|
ADD PRIMARY KEY (`post_id`,`tag_id`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_states`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_tags`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `blog_translations`
|
|
ADD PRIMARY KEY (`postTranslationID`);");
|
|
|
|
$this->db->query("ALTER TABLE `calendar`
|
|
ADD PRIMARY KEY (`id`);");
|
|
|
|
$this->db->query("ALTER TABLE `feedback`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `feedback_archive`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `feedback_states`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `files`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `notifications`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `projects`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `projects_categories`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `projects_entry_votes`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `projects_translations`
|
|
ADD PRIMARY KEY (`translationID`),
|
|
ADD UNIQUE KEY `projectID` (`projectID`,`lang`);");
|
|
|
|
$this->db->query("ALTER TABLE `redirects`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `social_posts`
|
|
ADD PRIMARY KEY (`post_id`),
|
|
ADD UNIQUE KEY `post_url` (`post_url`);");
|
|
|
|
$this->db->query("ALTER TABLE `users`
|
|
ADD UNIQUE KEY `id` (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `users_history`
|
|
ADD UNIQUE KEY `changeID` (`changeID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts`
|
|
ADD PRIMARY KEY (`ID`),
|
|
ADD UNIQUE KEY `user_posts_ID_uindex` (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_hashtags`
|
|
ADD PRIMARY KEY (`ID`),
|
|
ADD UNIQUE KEY `user_posts_hashtags_ID_uindex` (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_likes`
|
|
ADD PRIMARY KEY (`postID`,`likerUserID`),
|
|
ADD UNIQUE KEY `postID_2` (`postID`,`likerUserID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_media`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_mentions`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_reports`
|
|
ADD PRIMARY KEY (`ID`);");
|
|
}
|
|
|
|
private function addAutoIncrements() {
|
|
$this->db->query("ALTER TABLE `blog_categories`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;");
|
|
|
|
$this->db->query("ALTER TABLE `blog_comments`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;");
|
|
|
|
$this->db->query("ALTER TABLE `blog_content`
|
|
MODIFY `contentID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=89;");
|
|
|
|
$this->db->query("ALTER TABLE `blog_posts`
|
|
MODIFY `postID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=98;");
|
|
|
|
$this->db->query("ALTER TABLE `blog_states`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;");
|
|
|
|
$this->db->query("ALTER TABLE `blog_tags`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=61;");
|
|
|
|
$this->db->query("ALTER TABLE `blog_translations`
|
|
MODIFY `postTranslationID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34;");
|
|
|
|
$this->db->query("ALTER TABLE `calendar`
|
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;");
|
|
|
|
$this->db->query("ALTER TABLE `feedback`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;");
|
|
|
|
$this->db->query("ALTER TABLE `feedback_archive`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;");
|
|
|
|
$this->db->query("ALTER TABLE `files`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=125;");
|
|
|
|
$this->db->query("ALTER TABLE `notifications`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=74;");
|
|
|
|
$this->db->query("ALTER TABLE `projects`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=64;");
|
|
|
|
$this->db->query("ALTER TABLE `projects_categories`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;");
|
|
|
|
$this->db->query("ALTER TABLE `projects_entry_votes`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=260;");
|
|
|
|
$this->db->query("ALTER TABLE `projects_translations`
|
|
MODIFY `translationID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36;");
|
|
|
|
$this->db->query("ALTER TABLE `redirects`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=47;");
|
|
|
|
$this->db->query("ALTER TABLE `social_posts`
|
|
MODIFY `post_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=484298;");
|
|
|
|
$this->db->query("ALTER TABLE `users`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;");
|
|
|
|
$this->db->query("ALTER TABLE `users_history`
|
|
MODIFY `changeID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=209;");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_hashtags`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_media`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_mentions`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;");
|
|
|
|
$this->db->query("ALTER TABLE `user_posts_reports`
|
|
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT;");
|
|
}
|
|
|
|
private function addConstraints() {
|
|
$this->db->query("ALTER TABLE `blog_post_likes`
|
|
ADD CONSTRAINT `fk_post_likes_post` FOREIGN KEY (`post_id`) REFERENCES `blog_posts` (`postID`),
|
|
ADD CONSTRAINT `fk_post_likes_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`ID`);");
|
|
}
|
|
|
|
private function fillBlogTables()
|
|
{
|
|
if ($this->db->query('SELECT COUNT(*) count FROM blog_categories')->result_array()[0]['count'] == 0) {
|
|
$this->db->query("INSERT INTO `blog_categories` (`ID`, `name`, `display_name`) VALUES
|
|
(1, 'design', 'Design'),
|
|
(2, 'development', 'Entwicklung & Programmierung'),
|
|
(3, 'internet', 'Internet'),
|
|
(4, 'minepoint', 'MinePoint'),
|
|
(5, 'social_media', 'Soziale Medien'),
|
|
(6, 'technic', 'Technik'),
|
|
(7, 'youtube', 'YouTube')");
|
|
}
|
|
if ($this->db->query('SELECT COUNT(*) count FROM blog_states')->result_array()[0]['count'] == 0) {
|
|
$this->db->query("INSERT INTO `blog_states` (`ID`, `name`, `display_name`) VALUES
|
|
(1, 'published', 'Veröffentlicht'),
|
|
(2, 'draft', 'Entwurf'),
|
|
(3, 'pending', 'Geplant'),
|
|
(4, 'trashbin', 'Im Papierkorb')");
|
|
}
|
|
if ($this->db->query('SELECT COUNT(*) count FROM blog_tags')->result_array()[0]['count'] == 0) {
|
|
$this->db->query("INSERT INTO `blog_tags` (`ID`, `name`, `display_name`) VALUES
|
|
(1, 'youtube', 'YouTube'),
|
|
(2, 'twitter', 'Twitter'),
|
|
(3, 'smartphones', 'Smartphones'),
|
|
(4, 'coding', 'Programmieren'),
|
|
(5, 'development', 'Entwicklung'),
|
|
(6, 'design', 'Design'),
|
|
(7, 'adobe', 'Adobe'),
|
|
(8, '3d', '3D'),
|
|
(9, 'ux', 'User Experience'),
|
|
(10, 'ui', 'User Interface'),
|
|
(11, 'design-thinking', 'Thinking on Design'),
|
|
(12, 'games', 'Spiele'),
|
|
(13, 'hardware', 'Hardware'),
|
|
(14, 'software', 'Software'),
|
|
(15, 'photography', 'Fotografie'),
|
|
(16, 'videos', 'Videos & Filmen'),
|
|
(17, 'learning', 'Lernen'),
|
|
(34, 'programmiersprachen', 'Programmiersprachen'),
|
|
(35, 'sprachen', 'Sprachen'),
|
|
(36, 'serie', 'Serie'),
|
|
(37, 'kanal', 'Kanal'),
|
|
(38, 'neu', 'Neu'),
|
|
(39, 'kingofdog', 'KingOfDog'),
|
|
(40, 'entwicklung', 'Entwicklung'),
|
|
(41, 'programmierung', 'Programmierung'),
|
|
(42, 'webseite', 'Webseite')");
|
|
}
|
|
}
|
|
|
|
private function fillFeedbackTable() {
|
|
if($this->db->query('SELECT COUNT(*) count FROM redirects')->result_array()[0]['count'] == 0) {
|
|
$this->db->query("INSERT INTO `feedback_states` (`ID`, `name`, `displayname`) VALUES
|
|
(0, 'new', 'ungelesen'),
|
|
(1, 'read', 'gelesen'),
|
|
(2, 'question', 'Rückfrage'),
|
|
(5, 'fixing', 'in Bearbeitung'),
|
|
(7, 'paused', 'pausiert'),
|
|
(10, 'closed', 'geschlossen'),
|
|
(15, 'fixed', 'geschlossen & gelöst');");
|
|
}
|
|
}
|
|
|
|
private function fillMainTable()
|
|
{
|
|
if ($this->db->query('SELECT COUNT(*) count FROM redirects')->result_array()[0]['count'] == 0) {
|
|
$this->db->query("INSERT INTO `redirects` (`ID`, `date`, `redirect`, `url`, `temporary`, `expireDate`) VALUES
|
|
(1, '2016-10-15 18:09:51', 'yt', 'http://youtube.com/KingOfDog', 0, '0000-00-00 00:00:00'),
|
|
(2, '2016-10-15 18:10:13', 'youtube', 'http://youtube.com/KingOfDog', 0, '0000-00-00 00:00:00'),
|
|
(3, '2016-10-15 18:10:27', 'tw', 'http://twitter.com/KingOfDogTV', 0, '0000-00-00 00:00:00'),
|
|
(4, '2016-10-15 18:10:37', 'twitter', 'http://twitter.com/KingOfDogTV', 0, '0000-00-00 00:00:00')");
|
|
}
|
|
}
|
|
|
|
private function fillProjectsTable()
|
|
{
|
|
if ($this->db->query('SELECT COUNT(*) count FROM projects_categories')->result_array()[0]['count'] == 0) {
|
|
$this->db->query("INSERT INTO `projects_categories` (`ID`, `collection`, `displayname`, `displaynameEnglish`, `displaynameFrench`) VALUES
|
|
(1, 'banner', 'Banner', 'Banner', 'Bannière'),
|
|
(2, 'fotografie', 'Fotografie', 'Photography', 'Photographie'),
|
|
(3, 'minecraft', 'Minecraft', 'Minecraft', 'Minecraft'),
|
|
(4, 'websites', 'Webseiten', 'Websites', 'Sites'),
|
|
(5, 'logo', 'Logo', 'Logo', 'Logo'),
|
|
(6, 'development', 'Programmierung', 'Development', ''),
|
|
(7, 'games', 'Spiele', 'Games', ''),
|
|
(8, 'design', 'Design', 'Design', 'Design')");
|
|
}
|
|
}
|
|
} |