Move schema to json

This commit is contained in:
Dennis Eichhorn 2018-12-23 15:18:00 +01:00
parent 6381562b95
commit d4eedecb53
2 changed files with 60 additions and 35 deletions

60
Admin/Install/db.json Normal file
View File

@ -0,0 +1,60 @@
{
"monitoring_file": {
"name": "monitoring_file",
"fields": {
"monitoring_file_id": {
"name": "monitoring_file_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"monitoring_file_path": {
"name": "monitoring_file_path",
"type": "VARCHAR(255)",
"default": null,
"null": true
},
"monitoring_file_modified": {
"name": "monitoring_file_modified",
"type": "DATETIME",
"null": false
},
"monitoring_file_deprecated": {
"name": "monitoring_file_deprecated",
"type": "TINYINT",
"null": false
},
"monitoring_file_dangerous": {
"name": "monitoring_file_dangerous",
"type": "TINYINT",
"null": false
},
"monitoring_file_unicode": {
"name": "monitoring_file_unicode",
"type": "TINYINT",
"null": false
},
"monitoring_file_version": {
"name": "monitoring_file_version",
"type": "TINYINT",
"null": false
},
"monitoring_file_hash": {
"name": "monitoring_file_hash",
"type": "TINYINT",
"null": false
},
"monitoring_file_status": {
"name": "monitoring_file_status",
"type": "TINYINT",
"null": false
},
"monitoring_file_inspected": {
"name": "monitoring_file_inspected",
"type": "DATETIME",
"null": false
}
}
}
}

View File

@ -14,9 +14,6 @@ declare(strict_types=1);
namespace Modules\Monitoring\Admin;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\DataStorage\Database\DatabaseType;
use phpOMS\Module\InfoManager;
use phpOMS\Module\InstallerAbstract;
/**
@ -29,36 +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->beginTransaction();
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'monitoring_file` (
`monitoring_file_id` int(11) NOT NULL AUTO_INCREMENT,
`monitoring_file_path` text DEFAULT NULL,
`monitoring_file_modified` datetime NOT NULL,
`monitoring_file_deprecated` tinyint(1) NOT NULL,
`monitoring_file_dangerous` tinyint(1) NOT NULL,
`monitoring_file_unicode` tinyint(1) NOT NULL,
`monitoring_file_version` tinyint(1) NOT NULL,
`monitoring_file_hash` tinyint(1) NOT NULL,
`monitoring_file_status` tinyint(1) NOT NULL,
`monitoring_file_inspected` datetime NOT NULL,
PRIMARY KEY (`monitoring_file_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get()->con->commit();
break;
}
}
}