From af6e5bb2d9138aafd093d9d126be503814936e37 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 22 Dec 2018 19:51:26 +0100 Subject: [PATCH] Move schema to json --- Admin/Install/db.json | 71 +++++++++++++++++++++++++++++++++++++++++++ Admin/Installer.php | 35 --------------------- 2 files changed, 71 insertions(+), 35 deletions(-) create mode 100644 Admin/Install/db.json diff --git a/Admin/Install/db.json b/Admin/Install/db.json new file mode 100644 index 0000000..5acb2e9 --- /dev/null +++ b/Admin/Install/db.json @@ -0,0 +1,71 @@ +{ + "auditor_audit": { + "name": "auditor_audit", + "fields": { + "auditor_audit_id": { + "name": "auditor_audit_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "auditor_audit_module": { + "name": "auditor_audit_module", + "type": "VARCHAR(255)", + "default": null, + "null": true + }, + "auditor_audit_ref": { + "name": "auditor_audit_ref", + "type": "INT", + "default": null, + "null": true + }, + "auditor_audit_type": { + "name": "auditor_audit_type", + "type": "TINYINT", + "null": false + }, + "auditor_audit_subtype": { + "name": "auditor_audit_subtype", + "type": "TINYINT", + "null": false + }, + "auditor_audit_content": { + "name": "auditor_audit_content", + "type": "TEXT", + "default": null, + "null": true + }, + "auditor_audit_old": { + "name": "auditor_audit_old", + "type": "TEXT", + "default": null, + "null": true + }, + "auditor_audit_new": { + "name": "auditor_audit_new", + "type": "TEXT", + "default": null, + "null": true + }, + "auditor_audit_created_at": { + "name": "auditor_audit_created_at", + "type": "DATETIME", + "null": false + }, + "auditor_audit_created_by": { + "name": "auditor_audit_created_by", + "type": "INT", + "null": false, + "foreignTable": "account", + "foreignKey": "account_id" + }, + "auditor_audit_ip": { + "name": "auditor_audit_ip", + "type": "INT", + "null": false + } + } + } +} \ No newline at end of file diff --git a/Admin/Installer.php b/Admin/Installer.php index 53413cc..f432c7c 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -29,39 +29,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 . 'auditor_audit` ( - `auditor_audit_id` int(11) NOT NULL AUTO_INCREMENT, - `auditor_audit_module` varchar(255) DEFAULT NULL, - `auditor_audit_ref` int(11) DEFAULT NULL, - `auditor_audit_type` smallint(3) NOT NULL, - `auditor_audit_subtype` smallint(3) NOT NULL, - `auditor_audit_content` text DEFAULT NULL, - `auditor_audit_old` text DEFAULT NULL, - `auditor_audit_new` text DEFAULT NULL, - `auditor_audit_created_at` datetime NOT NULL, - `auditor_audit_created_by` int(11) NOT NULL, - `auditor_audit_ip` int(11) NOT NULL, - PRIMARY KEY (`auditor_audit_id`), - KEY `auditor_audit_created_by` (`auditor_audit_created_by`) - )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' - )->execute(); - - $dbPool->get()->con->prepare( - 'ALTER TABLE `' . $dbPool->get()->prefix . 'auditor_audit` - ADD CONSTRAINT `' . $dbPool->get()->prefix . 'auditor_audit_ibfk_1` FOREIGN KEY (`auditor_audit_created_by`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);' - )->execute(); - break; - } - } }