diff --git a/Admin/Install/db.json b/Admin/Install/db.json new file mode 100644 index 0000000..28ea0e9 --- /dev/null +++ b/Admin/Install/db.json @@ -0,0 +1,73 @@ +{ + "comments_list": { + "name": "comments_list", + "fields": { + "comments_list_id": { + "name": "comments_list_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + } + } + }, + "comments_comment": { + "name": "comments_comment", + "fields": { + "comments_comment_id": { + "name": "comments_comment_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "comments_comment_status": { + "name": "comments_comment_status", + "type": "TINYINT", + "null": false + }, + "comments_comment_title": { + "name": "comments_comment_title", + "type": "VARCHAR(255)", + "null": false + }, + "comments_comment_content": { + "name": "comments_comment_content", + "type": "TEXT", + "null": false + }, + "comments_comment_content_raw": { + "name": "comments_comment_content_raw", + "type": "TEXT", + "null": false + }, + "comments_comment_list": { + "name": "comments_comment_list", + "type": "INT", + "null": false, + "foreignTable": "comments_list", + "foreignKey": "comments_list_id" + }, + "comments_comment_ref": { + "name": "comments_comment_ref", + "type": "INT", + "default": null, + "null": true, + "foreignTable": "comments_comment", + "foreignKey": "comments_comment_id" + }, + "comments_comment_created_by": { + "name": "comments_comment_created_by", + "type": "INT", + "null": false, + "foreignTable": "account", + "foreignKey": "account_id" + }, + "comments_comment_created_at": { + "name": "comments_comment_created_at", + "type": "DATETIME", + "null": false + } + } + } +} \ No newline at end of file diff --git a/Admin/Installer.php b/Admin/Installer.php index 8d37636..dc1cedc 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -14,13 +14,10 @@ declare(strict_types=1); namespace Modules\Comments\Admin; -use phpOMS\DataStorage\Database\DatabasePool; -use phpOMS\DataStorage\Database\DatabaseType; -use phpOMS\Module\InfoManager; use phpOMS\Module\InstallerAbstract; /** - * Calendar install class. + * Install class. * * @package Modules\Comments\Admin * @license OMS License 1.0 @@ -29,45 +26,4 @@ use phpOMS\Module\InstallerAbstract; */ class Installer extends InstallerAbstract { - - /** - * {@inheritdoc} - */ - public static function install(DatabasePool $dbPool, InfoManager $info) : void - { - parent::install($dbPool, $info); - - switch ($dbPool->get()->getType()) { - case DatabaseType::MYSQL: - $dbPool->get()->con->prepare( - 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'comments_list` ( - `comments_list_id` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`comments_list_id`) - )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' - )->execute(); - - $dbPool->get()->con->prepare( - 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'comments_comment` ( - `comments_comment_id` int(11) NOT NULL AUTO_INCREMENT, - `comments_comment_title` varchar(250) NOT NULL, - `comments_comment_content` text NOT NULL, - `comments_comment_list` int(11) DEFAULT NULL, - `comments_comment_ref` int(11) DEFAULT NULL, - `comments_comment_created_at` datetime NOT NULL, - `comments_comment_created_by` int(11) NOT NULL, - PRIMARY KEY (`comments_comment_id`), - KEY `comments_comment_ref` (`comments_comment_ref`), - KEY `comments_comment_created_by` (`comments_comment_created_by`) - )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' - )->execute(); - - $dbPool->get()->con->prepare( - 'ALTER TABLE `' . $dbPool->get()->prefix . 'comments_comment` - ADD CONSTRAINT `' . $dbPool->get()->prefix . 'comments_comment_ibfk_1` FOREIGN KEY (`comments_comment_list`) REFERENCES `' . $dbPool->get()->prefix . 'comments_list` (`comments_list_id`), - ADD CONSTRAINT `' . $dbPool->get()->prefix . 'comments_comment_ibfk_2` FOREIGN KEY (`comments_comment_ref`) REFERENCES `' . $dbPool->get()->prefix . 'comments_comment` (`comments_comment_id`), - ADD CONSTRAINT `' . $dbPool->get()->prefix . 'comments_comment_ibfk_3` FOREIGN KEY (`comments_comment_created_by`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);' - )->execute(); - break; - } - } }