Move schema to json

This commit is contained in:
Dennis Eichhorn 2018-12-22 19:51:26 +01:00
parent a7b1f13e9d
commit af6e5bb2d9
2 changed files with 71 additions and 35 deletions

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

@ -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
}
}
}
}

View File

@ -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;
}
}
}