Update automatic generation of database tables
This commit is contained in:
parent
0ea56d1292
commit
df472263ce
|
@ -6,288 +6,663 @@ class DatabaseModel extends CI_Model
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->createMissingDatbases();
|
||||
$this->createMissingDatabases();
|
||||
}
|
||||
|
||||
public function createMissingDatbases() {
|
||||
$this->createDatabases();
|
||||
public function createMissingDatabases()
|
||||
{
|
||||
//$this->createDatabases();
|
||||
$this->createTables();
|
||||
$this->fillBlogDb();
|
||||
$this->fillMainDb();
|
||||
$this->fillPortfolioDb();
|
||||
//$this->addIndices();
|
||||
//$this->addAutoIncrements();
|
||||
//$this->addConstraints();
|
||||
|
||||
$this->fillBlogTables();
|
||||
$this->fillFeedbackTable();
|
||||
$this->fillMainTable();
|
||||
$this->fillProjectsTable();
|
||||
}
|
||||
|
||||
public function createDatabases() {
|
||||
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 */;');
|
||||
}
|
||||
|
||||
|
||||
public function createTables()
|
||||
private function createTables()
|
||||
{
|
||||
// Calendar Table
|
||||
$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 AUTO_INCREMENT=3 DEFAULT CHARSET=latin1');
|
||||
// Feedback Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `feedback` (
|
||||
`ID` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`page` VARCHAR(100) DEFAULT NULL,
|
||||
`message` TEXT,
|
||||
`datetime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
`anonymous` TINYINT(1) DEFAULT \'1\',
|
||||
`userID` INT(11) DEFAULT NULL,
|
||||
`email` VARCHAR(50) DEFAULT NULL,
|
||||
PRIMARY KEY (`ID`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1');
|
||||
// Files Table
|
||||
$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 AUTO_INCREMENT=72 DEFAULT CHARSET=latin1');
|
||||
// Redirects Table
|
||||
$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 AUTO_INCREMENT=220 DEFAULT CHARSET=latin1');
|
||||
// User Followers Table
|
||||
$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');
|
||||
// User Posts Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `user_posts` (
|
||||
`ID` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` INT(11) DEFAULT NULL,
|
||||
`title` VARCHAR(150) NOT NULL,
|
||||
`content` TEXT,
|
||||
`date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`reply_to` INT(11) DEFAULT NULL,
|
||||
$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 `user_posts_ID_uindex` (`ID`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=145 DEFAULT CHARSET=latin1');
|
||||
// User Posts Likes Table
|
||||
$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,
|
||||
UNIQUE KEY `likerUserID` (`likerUserID`),
|
||||
UNIQUE KEY `postID` (`postID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1');
|
||||
// Users Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `users` (
|
||||
`ID` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`original_name` VARCHAR(25) NOT NULL,
|
||||
`username` VARCHAR(25) NOT NULL,
|
||||
`displayname` VARCHAR(25) NOT NULL,
|
||||
`login_method` INT(11) DEFAULT \'0\',
|
||||
`password` TEXT,
|
||||
`email` TEXT NOT NULL,
|
||||
`rank` TEXT NOT NULL,
|
||||
`profile_picture` TEXT NOT NULL,
|
||||
`header_image` TEXT,
|
||||
`social_networks` TEXT,
|
||||
`is_activated` TINYINT(1) NOT NULL,
|
||||
`activation_key` VARCHAR(256) DEFAULT NULL,
|
||||
`showAds` TINYINT(1) NOT NULL DEFAULT \'1\',
|
||||
`date_created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`isCurrentlyOnline` TINYINT(1) DEFAULT \'0\',
|
||||
`about` TEXT NOT NULL,
|
||||
`lastLogin` DATETIME NOT NULL,
|
||||
`language` VARCHAR(10) DEFAULT \'DE\',
|
||||
`country` VARCHAR(2) DEFAULT NULL,
|
||||
`gender` VARCHAR(10) DEFAULT NULL,
|
||||
`receiveEmails` TINYINT(1) NOT NULL DEFAULT \'1\',
|
||||
`receiveNewsletter` TINYINT(1) NOT NULL DEFAULT \'1\',
|
||||
`forget_password_key` VARCHAR(256) DEFAULT NULL,
|
||||
`isDeleted` TINYINT(1) DEFAULT \'0\',
|
||||
UNIQUE KEY `id` (`ID`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1');
|
||||
// Users History Table
|
||||
$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,
|
||||
`receiveEmails` TINYINT(1) NOT NULL DEFAULT \'1\',
|
||||
`receiveNewsletter` TINYINT(1) NOT NULL DEFAULT \'1\',
|
||||
UNIQUE KEY `changeID` (`changeID`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1');
|
||||
// Blog Categories Table
|
||||
$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 AUTO_INCREMENT=18 DEFAULT CHARSET=latin1');
|
||||
// Blog Comments Table
|
||||
$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 AUTO_INCREMENT=2 DEFAULT CHARSET=latin1');
|
||||
// Blog Content Table
|
||||
$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 NOT NULL,
|
||||
`contentAuthorID` INT(11) DEFAULT NULL,
|
||||
`isNativePost` TINYINT(1) NOT NULL,
|
||||
`isActive` TINYINT(1) NOT NULL,
|
||||
`versionMessage` VARCHAR(300) NOT NULL,
|
||||
`language` VARCHAR(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`contentID`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=latin1');
|
||||
// Blog Posts Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_posts` (
|
||||
`postID` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`postUrl` VARCHAR(300) NOT NULL,
|
||||
`postTitle` VARCHAR(255) DEFAULT NULL,
|
||||
`postDesc` TEXT,
|
||||
`postPublishDate` DATETIME DEFAULT NULL,
|
||||
`postLastEdit` DATETIME DEFAULT NULL,
|
||||
`postAuthorID` INT(11) DEFAULT NULL,
|
||||
`postImage` TEXT NOT NULL,
|
||||
`postState` VARCHAR(50) 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 AUTO_INCREMENT=43 DEFAULT CHARSET=latin1');
|
||||
// Blog Post Likes Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_post_likes` (
|
||||
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,
|
||||
PRIMARY KEY (`post_id`,`user_id`),
|
||||
`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');
|
||||
// Blog Post Tags Table
|
||||
$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');
|
||||
// Blog States Table
|
||||
$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,
|
||||
) 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 AUTO_INCREMENT=5 DEFAULT CHARSET=latin1');
|
||||
// Blog Tags Table
|
||||
$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,
|
||||
) 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 AUTO_INCREMENT=49 DEFAULT CHARSET=latin1');
|
||||
// Blog Translations Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_translations` (
|
||||
`postID` INT(11) DEFAULT NULL,
|
||||
`language` VARCHAR(10) DEFAULT \'en\',
|
||||
`postTitle` VARCHAR(255) DEFAULT NULL,
|
||||
`postDesc` TEXT,
|
||||
UNIQUE KEY `blog_translations_language_uindex` (`language`),
|
||||
UNIQUE KEY `blog_translations_postID_uindex` (`postID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1');
|
||||
// Collections Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `collections` (
|
||||
`ID` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`collection` TEXT NOT NULL,
|
||||
`displayname` TEXT NOT NULL,
|
||||
`displaynameEnglish` TEXT NOT NULL,
|
||||
`displaynameFrench` TEXT NOT NULL,
|
||||
) 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 AUTO_INCREMENT=17 DEFAULT CHARSET=latin1');
|
||||
// Portfolio Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `portfolio` (
|
||||
`ID` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`datetime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`source` TEXT NOT NULL,
|
||||
`isDownloadable` TINYINT(1) NOT NULL DEFAULT \'0\',
|
||||
`isOpenSource` TINYINT(1) NOT NULL DEFAULT \'0\',
|
||||
`title` TEXT NOT NULL,
|
||||
`titleEnglish` TEXT NOT NULL,
|
||||
`titleFrench` TEXT NOT NULL,
|
||||
`headline` TEXT NOT NULL,
|
||||
`headlineEnglish` TEXT NOT NULL,
|
||||
`headlineFrench` TEXT NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
`descriptionEnglish` TEXT NOT NULL,
|
||||
`descriptionFrench` TEXT NOT NULL,
|
||||
PRIMARY KEY (`ID`),
|
||||
UNIQUE KEY `name` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=latin1');
|
||||
// Project Categories Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `project_categories` (
|
||||
`projectID` INT(11) NOT NULL,
|
||||
`categoryID` INT(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1');
|
||||
// Social Posts Table
|
||||
$this->db->query('CREATE TABLE IF NOT EXISTS `social_posts` (
|
||||
`post_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`post_plattform` VARCHAR(20) NOT NULL,
|
||||
`post_content` TEXT NOT NULL,
|
||||
`post_url` VARCHAR(75) NOT NULL,
|
||||
`post_author` VARCHAR(20) NOT NULL,
|
||||
`post_author_url` TEXT NOT NULL,
|
||||
`post_date` INT(11) NOT NULL,
|
||||
`post_img_source` TEXT,
|
||||
`post_original_id` BIGINT(20) NOT NULL,
|
||||
) 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 AUTO_INCREMENT=5474 DEFAULT CHARSET=latin1');
|
||||
) 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;");
|
||||
}
|
||||
|
||||
public function fillBlogDb() {
|
||||
if($this->db->query('SELECT COUNT(*) count FROM blog_categories')->result_array()[0]['count'] == 0) {
|
||||
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'),
|
||||
|
@ -297,14 +672,14 @@ class DatabaseModel extends CI_Model
|
|||
(6, 'technic', 'Technik'),
|
||||
(7, 'youtube', 'YouTube')");
|
||||
}
|
||||
if($this->db->query('SELECT COUNT(*) count FROM blog_states')->result_array()[0]['count'] == 0) {
|
||||
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) {
|
||||
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'),
|
||||
|
@ -323,12 +698,6 @@ class DatabaseModel extends CI_Model
|
|||
(15, 'photography', 'Fotografie'),
|
||||
(16, 'videos', 'Videos & Filmen'),
|
||||
(17, 'learning', 'Lernen'),
|
||||
(28, '', ''),
|
||||
(29, 'test', 'test'),
|
||||
(30, 'kacke', 'kacke'),
|
||||
(31, 'asdfla', 'asdfla'),
|
||||
(32, 'admin', 'Admin'),
|
||||
(33, 'tset', 'tset'),
|
||||
(34, 'programmiersprachen', 'Programmiersprachen'),
|
||||
(35, 'sprachen', 'Sprachen'),
|
||||
(36, 'serie', 'Serie'),
|
||||
|
@ -337,18 +706,26 @@ class DatabaseModel extends CI_Model
|
|||
(39, 'kingofdog', 'KingOfDog'),
|
||||
(40, 'entwicklung', 'Entwicklung'),
|
||||
(41, 'programmierung', 'Programmierung'),
|
||||
(42, 'webseite', 'Webseite'),
|
||||
(43, 'posts', 'Posts'),
|
||||
(44, 'post', 'Post'),
|
||||
(45, 'system', 'System'),
|
||||
(46, 'nutzer', 'Nutzer'),
|
||||
(47, 'user', 'User'),
|
||||
(48, 'php', 'PHP')");
|
||||
(42, 'webseite', 'Webseite')");
|
||||
}
|
||||
}
|
||||
|
||||
public function fillMainDb() {
|
||||
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'),
|
||||
|
@ -357,8 +734,9 @@ class DatabaseModel extends CI_Model
|
|||
}
|
||||
}
|
||||
|
||||
public function fillPortfolioDb() {
|
||||
if($this->db->query('SELECT COUNT(*) count FROM projects_categories')->result_array()[0]['count'] == 0) {
|
||||
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'),
|
||||
|
|
Reference in New Issue
Block a user