Archived
1
0

Update automatic generation of database tables

This commit is contained in:
KingOfDog 2018-10-23 22:23:15 +02:00
parent 0ea56d1292
commit df472263ce

View File

@ -6,287 +6,662 @@ class DatabaseModel extends CI_Model
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->createMissingDatbases(); $this->createMissingDatabases();
} }
public function createMissingDatbases() { public function createMissingDatabases()
$this->createDatabases(); {
//$this->createDatabases();
$this->createTables(); $this->createTables();
$this->fillBlogDb(); //$this->addIndices();
$this->fillMainDb(); //$this->addAutoIncrements();
$this->fillPortfolioDb(); //$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 `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 `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 `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('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()
public function createTables()
{ {
// Calendar Table $this->db->query("CREATE TABLE IF NOT EXISTS `blog_categories` (
$this->db->query('CREATE TABLE IF NOT EXISTS `calendar` ( `ID` int(11) NOT NULL AUTO_INCREMENT,
`id` INT(11) NOT NULL AUTO_INCREMENT, `name` varchar(25) NOT NULL,
`title` VARCHAR(300) NOT NULL, `display_name` varchar(50) 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,
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`), PRIMARY KEY (`ID`),
UNIQUE KEY `blog_categories_name_display_name_uindex` (`name`, `display_name`) UNIQUE KEY `blog_categories_name_display_name_uindex` (`name`, `display_name`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1'); ) ENGINE = InnoDB DEFAULT CHARSET = latin1;");
// Blog Comments Table
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_comments` ( $this->db->query("CREATE TABLE IF NOT EXISTS `blog_comments` (
`ID` INT(11) NOT NULL AUTO_INCREMENT, `ID` int(11) NOT NULL AUTO_INCREMENT,
`post_id` INT(11) NOT NULL, `post_id` int(11) NOT NULL,
`user_id` INT(11) NOT NULL, `user_id` int(11) NOT NULL,
`comment` TEXT NOT NULL, `comment` text NOT NULL,
`date_created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`like_count` INT(11) NOT NULL, `like_count` int(11) NOT NULL,
`reply` TINYINT(1) NOT NULL DEFAULT \'0\', `reply` tinyint(1) NOT NULL DEFAULT '0',
`replyTo_id` INT(11) DEFAULT NULL, `replyTo_id` int(11) DEFAULT NULL,
PRIMARY KEY (`ID`) PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1'); ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
// Blog Content Table
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_content` ( $this->db->query("CREATE TABLE IF NOT EXISTS `blog_content` (
`contentID` INT(11) NOT NULL AUTO_INCREMENT, `contentID` int(11) NOT NULL AUTO_INCREMENT,
`postID` INT(11) NOT NULL, `postID` int(11) NOT NULL,
`contentDate` DATETIME NOT NULL, `contentDate` datetime NOT NULL,
`content` MEDIUMTEXT NOT NULL, `content` mediumtext COLLATE utf8mb4_bin NOT NULL,
`contentAuthorID` INT(11) DEFAULT NULL, `contentAuthorID` int(11) DEFAULT NULL,
`isNativePost` TINYINT(1) NOT NULL, `isNativePost` tinyint(1) NOT NULL,
`isActive` TINYINT(1) NOT NULL, `isActive` tinyint(1) NOT NULL,
`versionMessage` VARCHAR(300) NOT NULL, `versionMessage` varchar(300) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`language` VARCHAR(10) DEFAULT NULL, `language` varchar(10) CHARACTER SET latin1 DEFAULT NULL,
`wordCount` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`contentID`) PRIMARY KEY (`contentID`)
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=latin1'); ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
// Blog Posts Table
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_posts` ( $this->db->query("CREATE TABLE IF NOT EXISTS `blog_posts` (
`postID` INT(11) NOT NULL AUTO_INCREMENT, `postID` int(11) NOT NULL AUTO_INCREMENT,
`postUrl` VARCHAR(300) NOT NULL, `postUrl` varchar(300) CHARACTER SET latin1 DEFAULT NULL,
`postTitle` VARCHAR(255) DEFAULT NULL, `postPublishDate` datetime DEFAULT NULL,
`postDesc` TEXT, `postLastEdit` datetime DEFAULT NULL,
`postPublishDate` DATETIME DEFAULT NULL, `postAuthorID` int(11) DEFAULT NULL,
`postLastEdit` DATETIME DEFAULT NULL, `postImage` text CHARACTER SET latin1,
`postAuthorID` INT(11) DEFAULT NULL, `postState` varchar(50) CHARACTER SET latin1 NOT NULL,
`postImage` TEXT NOT NULL, `postViews` int(11) NOT NULL DEFAULT '0',
`postState` VARCHAR(50) NOT NULL, `postCategoryID` int(11) NOT NULL,
`postViews` INT(11) NOT NULL DEFAULT \'0\', `postIsDeleted` tinyint(1) NOT NULL DEFAULT '0',
`postCategoryID` INT(11) NOT NULL, `postDeletedDate` datetime DEFAULT NULL,
`postIsDeleted` TINYINT(1) NOT NULL DEFAULT \'0\',
`postDeletedDate` DATETIME DEFAULT NULL,
PRIMARY KEY (`postID`) PRIMARY KEY (`postID`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1'); ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
// Blog Post Likes Table
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_post_likes` ( $this->db->query("CREATE TABLE IF NOT EXISTS `blog_post_likes` (
`post_id` int(11) NOT NULL, `post_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL, `user_id` int(11) NOT NULL,
PRIMARY KEY (`post_id`, `user_id`), PRIMARY KEY (`post_id`, `user_id`),
KEY `fk_post_likes_user` (`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_post` FOREIGN KEY (`post_id`) REFERENCES `blog_posts` (`postID`),
CONSTRAINT `fk_post_likes_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`ID`) CONSTRAINT `fk_post_likes_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1'); ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
// Blog Post Tags Table
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_post_tags` ( $this->db->query("CREATE TABLE IF NOT EXISTS `blog_post_tags` (
`post_id` INT(11) NOT NULL, `post_id` int(11) NOT NULL,
`tag_id` INT(11) NOT NULL, `tag_id` int(11) NOT NULL,
PRIMARY KEY (`post_id`, `tag_id`) PRIMARY KEY (`post_id`, `tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1'); ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
// Blog States Table
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_states` ( $this->db->query("CREATE TABLE IF NOT EXISTS `blog_states` (
`ID` INT(11) NOT NULL AUTO_INCREMENT, `ID` int(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(15) NOT NULL, `name` varchar(15) NOT NULL,
`display_name` VARCHAR(15) NOT NULL, `display_name` varchar(15) NOT NULL,
PRIMARY KEY (`ID`) PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1'); ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
// Blog Tags Table
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_tags` ( $this->db->query("CREATE TABLE IF NOT EXISTS `blog_tags` (
`ID` INT(11) NOT NULL AUTO_INCREMENT, `ID` int(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(25) NOT NULL, `name` varchar(25) NOT NULL,
`display_name` VARCHAR(50) NOT NULL, `display_name` varchar(50) NOT NULL,
PRIMARY KEY (`ID`) PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=latin1'); ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
// Blog Translations Table
$this->db->query('CREATE TABLE IF NOT EXISTS `blog_translations` ( $this->db->query("CREATE TABLE IF NOT EXISTS `blog_translations` (
`postID` INT(11) DEFAULT NULL, `postTranslationID` int(11) NOT NULL AUTO_INCREMENT,
`language` VARCHAR(10) DEFAULT \'en\', `postID` int(11) NOT NULL,
`postTitle` VARCHAR(255) DEFAULT NULL, `language` varchar(5) COLLATE utf8mb4_bin NOT NULL DEFAULT 'de',
`postDesc` TEXT, `postTitle` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
UNIQUE KEY `blog_translations_language_uindex` (`language`), `postDesc` text COLLATE utf8mb4_bin,
UNIQUE KEY `blog_translations_postID_uindex` (`postID`) PRIMARY KEY (`postTranslationID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1'); ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
// Collections Table
$this->db->query('CREATE TABLE IF NOT EXISTS `collections` ( $this->db->query("CREATE TABLE IF NOT EXISTS `calendar` (
`ID` INT(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`collection` TEXT NOT NULL, `title` varchar(300) NOT NULL,
`displayname` TEXT NOT NULL, `allDay` tinyint(1) NOT NULL,
`displaynameEnglish` TEXT NOT NULL, `start` varchar(20) NOT NULL,
`displaynameFrench` TEXT 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`) PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=latin1'); ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
// Portfolio Table
$this->db->query('CREATE TABLE IF NOT EXISTS `portfolio` ( $this->db->query("CREATE TABLE IF NOT EXISTS `feedback` (
`ID` INT(11) NOT NULL AUTO_INCREMENT, `ID` int(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL, `page` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
`datetime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `message` text COLLATE utf8mb4_bin,
`source` TEXT NOT NULL, `datetime` datetime DEFAULT CURRENT_TIMESTAMP,
`isDownloadable` TINYINT(1) NOT NULL DEFAULT \'0\', `anonymous` tinyint(1) DEFAULT '1',
`isOpenSource` TINYINT(1) NOT NULL DEFAULT \'0\', `userID` int(11) DEFAULT NULL,
`title` TEXT NOT NULL, `email` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
`titleEnglish` TEXT NOT NULL, `feedbackState` int(11) NOT NULL DEFAULT '0',
`titleFrench` TEXT NOT NULL, `lastStateUpdate` datetime DEFAULT NULL,
`headline` TEXT NOT NULL, `feedbackStatusMessage` text COLLATE utf8mb4_bin,
`headlineEnglish` TEXT NOT NULL, `supporterID` int(11) DEFAULT NULL,
`headlineFrench` TEXT NOT NULL, PRIMARY KEY (`ID`)
`description` TEXT NOT NULL, ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
`descriptionEnglish` TEXT NOT NULL,
`descriptionFrench` TEXT NOT NULL, $this->db->query("CREATE TABLE IF NOT EXISTS `feedback_archive` (
PRIMARY KEY (`ID`), `ID` int(11) NOT NULL AUTO_INCREMENT,
UNIQUE KEY `name` (`name`) `page` varchar(100) CHARACTER SET latin1 DEFAULT NULL,
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=latin1'); `message` text COLLATE utf8mb4_bin,
// Project Categories Table `datetime` datetime DEFAULT CURRENT_TIMESTAMP,
$this->db->query('CREATE TABLE IF NOT EXISTS `project_categories` ( `anonymous` tinyint(1) DEFAULT '1',
`projectID` INT(11) NOT NULL, `userID` int(11) DEFAULT NULL,
`categoryID` INT(11) NOT NULL `email` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=latin1'); `feedbackState` int(11) NOT NULL DEFAULT '0',
// Social Posts Table `feedbackStatusMessage` text COLLATE utf8mb4_bin,
$this->db->query('CREATE TABLE IF NOT EXISTS `social_posts` ( `supporterID` int(11) DEFAULT NULL,
`post_id` INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`ID`)
`post_plattform` VARCHAR(20) NOT NULL, ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;");
`post_content` TEXT NOT NULL,
`post_url` VARCHAR(75) NOT NULL, $this->db->query("CREATE TABLE IF NOT EXISTS `feedback_states` (
`post_author` VARCHAR(20) NOT NULL, `ID` int(11) NOT NULL AUTO_INCREMENT,
`post_author_url` TEXT NOT NULL, `name` varchar(50) NOT NULL,
`post_date` INT(11) NOT NULL, `displayname` text NOT NULL,
`post_img_source` TEXT, PRIMARY KEY (`ID`)
`post_original_id` BIGINT(20) NOT NULL, ) 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`), PRIMARY KEY (`post_id`),
UNIQUE KEY `post_url` (`post_url`) 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() { 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) { 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 $this->db->query("INSERT INTO `blog_categories` (`ID`, `name`, `display_name`) VALUES
(1, 'design', 'Design'), (1, 'design', 'Design'),
@ -323,12 +698,6 @@ class DatabaseModel extends CI_Model
(15, 'photography', 'Fotografie'), (15, 'photography', 'Fotografie'),
(16, 'videos', 'Videos & Filmen'), (16, 'videos', 'Videos & Filmen'),
(17, 'learning', 'Lernen'), (17, 'learning', 'Lernen'),
(28, '', ''),
(29, 'test', 'test'),
(30, 'kacke', 'kacke'),
(31, 'asdfla', 'asdfla'),
(32, 'admin', 'Admin'),
(33, 'tset', 'tset'),
(34, 'programmiersprachen', 'Programmiersprachen'), (34, 'programmiersprachen', 'Programmiersprachen'),
(35, 'sprachen', 'Sprachen'), (35, 'sprachen', 'Sprachen'),
(36, 'serie', 'Serie'), (36, 'serie', 'Serie'),
@ -337,17 +706,25 @@ class DatabaseModel extends CI_Model
(39, 'kingofdog', 'KingOfDog'), (39, 'kingofdog', 'KingOfDog'),
(40, 'entwicklung', 'Entwicklung'), (40, 'entwicklung', 'Entwicklung'),
(41, 'programmierung', 'Programmierung'), (41, 'programmierung', 'Programmierung'),
(42, 'webseite', 'Webseite'), (42, 'webseite', 'Webseite')");
(43, 'posts', 'Posts'),
(44, 'post', 'Post'),
(45, 'system', 'System'),
(46, 'nutzer', 'Nutzer'),
(47, 'user', 'User'),
(48, 'php', 'PHP')");
} }
} }
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) { 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 $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'), (1, '2016-10-15 18:09:51', 'yt', 'http://youtube.com/KingOfDog', 0, '0000-00-00 00:00:00'),
@ -357,7 +734,8 @@ class DatabaseModel extends CI_Model
} }
} }
public function fillPortfolioDb() { private function fillProjectsTable()
{
if ($this->db->query('SELECT COUNT(*) count FROM projects_categories')->result_array()[0]['count'] == 0) { 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 $this->db->query("INSERT INTO `projects_categories` (`ID`, `collection`, `displayname`, `displaynameEnglish`, `displaynameFrench`) VALUES
(1, 'banner', 'Banner', 'Banner', 'Bannière'), (1, 'banner', 'Banner', 'Banner', 'Bannière'),