mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-02-03 02:08:41 +00:00
Move schema to json
This commit is contained in:
parent
dff6b9d70a
commit
b971fc1329
149
Admin/Install/db.json
Normal file
149
Admin/Install/db.json
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
{
|
||||
"organization_unit": {
|
||||
"name": "organization_unit",
|
||||
"fields": {
|
||||
"organization_unit_id": {
|
||||
"name": "organization_unit_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"organization_unit_name": {
|
||||
"name": "organization_unit_name",
|
||||
"type": "VARCHAR(50)",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_unit_description": {
|
||||
"name": "organization_unit_description",
|
||||
"type": "TEXT",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_unit_descriptionraw": {
|
||||
"name": "organization_unit_descriptionraw",
|
||||
"type": "TEXT",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_unit_parent": {
|
||||
"name": "organization_unit_parent",
|
||||
"type": "INT",
|
||||
"default": null,
|
||||
"null": true,
|
||||
"foreignTable": "organization_unit",
|
||||
"foreignKey": "organization_unit_id"
|
||||
},
|
||||
"organization_unit_status": {
|
||||
"name": "organization_unit_status",
|
||||
"type": "TINYINT",
|
||||
"default": null,
|
||||
"null": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"organization_department": {
|
||||
"name": "organization_department",
|
||||
"fields": {
|
||||
"organization_department_id": {
|
||||
"name": "organization_department_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"organization_department_name": {
|
||||
"name": "organization_department_name",
|
||||
"type": "VARCHAR(50)",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_department_description": {
|
||||
"name": "organization_department_description",
|
||||
"type": "TEXT",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_department_descriptionraw": {
|
||||
"name": "organization_department_descriptionraw",
|
||||
"type": "TEXT",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_department_parent": {
|
||||
"name": "organization_department_parent",
|
||||
"type": "INT",
|
||||
"default": null,
|
||||
"null": true,
|
||||
"foreignTable": "organization_department",
|
||||
"foreignKey": "organization_department_id"
|
||||
},
|
||||
"organization_department_status": {
|
||||
"name": "organization_department_status",
|
||||
"type": "TINYINT",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_department_unit": {
|
||||
"name": "organization_department_unit",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "organization_unit",
|
||||
"foreignKey": "organization_unit_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"organization_position": {
|
||||
"name": "organization_position",
|
||||
"fields": {
|
||||
"organization_position_id": {
|
||||
"name": "organization_position_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"organization_position_name": {
|
||||
"name": "organization_position_name",
|
||||
"type": "VARCHAR(50)",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_position_description": {
|
||||
"name": "organization_position_description",
|
||||
"type": "TEXT",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_position_descriptionraw": {
|
||||
"name": "organization_position_descriptionraw",
|
||||
"type": "TEXT",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_position_parent": {
|
||||
"name": "organization_position_parent",
|
||||
"type": "INT",
|
||||
"default": null,
|
||||
"null": true,
|
||||
"foreignTable": "organization_position",
|
||||
"foreignKey": "organization_position_id"
|
||||
},
|
||||
"organization_position_status": {
|
||||
"name": "organization_position_status",
|
||||
"type": "TINYINT",
|
||||
"default": null,
|
||||
"null": true
|
||||
},
|
||||
"organization_position_department": {
|
||||
"name": "organization_position_department",
|
||||
"type": "INT",
|
||||
"default": null,
|
||||
"null": true,
|
||||
"foreignTable": "organization_department",
|
||||
"foreignKey": "organization_department_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Organization\Admin;
|
||||
|
||||
use Modules\Organization\Models\Unit;
|
||||
use Modules\Organization\Models\UnitMapper;
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\DataStorage\Database\DatabaseType;
|
||||
use phpOMS\Module\InfoManager;
|
||||
|
|
@ -37,96 +40,9 @@ class Installer extends InstallerAbstract
|
|||
{
|
||||
parent::install($dbPool, $info);
|
||||
|
||||
switch ($dbPool->get()->getType()) {
|
||||
case DatabaseType::MYSQL:
|
||||
$dbPool->get()->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'organization_unit` (
|
||||
`organization_unit_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`organization_unit_name` varchar(50) DEFAULT NULL,
|
||||
`organization_unit_description` text DEFAULT NULL,
|
||||
`organization_unit_descriptionraw` text DEFAULT NULL,
|
||||
`organization_unit_parent` int(11) DEFAULT NULL,
|
||||
`organization_unit_status` int(3) DEFAULT NULL,
|
||||
PRIMARY KEY (`organization_unit_id`),
|
||||
KEY `organization_unit_parent` (`organization_unit_parent`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
$unit = new Unit();
|
||||
$unit->setName('Orange Management');
|
||||
|
||||
$dbPool->get()->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get()->prefix . 'organization_unit`
|
||||
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'organization_unit_ibfk_1` FOREIGN KEY (`organization_unit_parent`) REFERENCES `' . $dbPool->get()->prefix . 'organization_unit` (`organization_unit_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get()->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'organization_department` (
|
||||
`organization_department_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`organization_department_name` varchar(30) DEFAULT NULL,
|
||||
`organization_department_description` text DEFAULT NULL,
|
||||
`organization_department_descriptionraw` text DEFAULT NULL,
|
||||
`organization_department_parent` int(11) DEFAULT NULL,
|
||||
`organization_department_status` int(3) DEFAULT NULL,
|
||||
`organization_department_unit` int(11) NOT NULL,
|
||||
PRIMARY KEY (`organization_department_id`),
|
||||
KEY `organization_department_parent` (`organization_department_parent`),
|
||||
KEY `organization_department_unit` (`organization_department_unit`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get()->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get()->prefix . 'organization_department`
|
||||
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'organization_department_ibfk_1` FOREIGN KEY (`organization_department_parent`) REFERENCES `' . $dbPool->get()->prefix . 'organization_department` (`organization_department_id`),
|
||||
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'organization_department_ibfk_2` FOREIGN KEY (`organization_department_unit`) REFERENCES `' . $dbPool->get()->prefix . 'organization_unit` (`organization_unit_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get()->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'organization_position` (
|
||||
`organization_position_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`organization_position_name` varchar(50) DEFAULT NULL,
|
||||
`organization_position_description` text DEFAULT NULL,
|
||||
`organization_position_descriptionraw` text DEFAULT NULL,
|
||||
`organization_position_parent` int(11) DEFAULT NULL,
|
||||
`organization_position_department` int(11) DEFAULT NULL,
|
||||
`organization_position_status` int(3) DEFAULT NULL,
|
||||
PRIMARY KEY (`organization_position_id`),
|
||||
KEY `organization_position_parent` (`organization_position_parent`),
|
||||
KEY `organization_position_department` (`organization_position_department`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get()->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get()->prefix . 'organization_position`
|
||||
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'organization_position_ibfk_1` FOREIGN KEY (`organization_position_parent`) REFERENCES `' . $dbPool->get()->prefix . 'organization_position` (`organization_position_id`),
|
||||
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'organization_position_ibfk_2` FOREIGN KEY (`organization_position_department`) REFERENCES `' . $dbPool->get()->prefix . 'organization_department` (`organization_department_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get()->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'organization_address` (
|
||||
`organization_address_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`organization_address_status` tinyint(2) DEFAULT NULL,
|
||||
`organization_address_matchcode` varchar(50) DEFAULT NULL,
|
||||
`organization_address_name` varchar(50) DEFAULT NULL,
|
||||
`organization_address_fao` varchar(30) DEFAULT NULL,
|
||||
`organization_address_addr` varchar(50) DEFAULT NULL,
|
||||
`organization_address_city` varchar(20) DEFAULT NULL,
|
||||
`organization_address_zip` varchar(20) DEFAULT NULL,
|
||||
`organization_address_state` varchar(20) DEFAULT NULL,
|
||||
`organization_address_country` varchar(30) DEFAULT NULL,
|
||||
`organization_address_unit` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`organization_address_id`),
|
||||
KEY `organization_address_unit` (`organization_address_unit`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get()->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get()->prefix . 'organization_address`
|
||||
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'organization_address_ibfk_1` FOREIGN KEY (`organization_address_unit`) REFERENCES `' . $dbPool->get()->prefix . 'organization_unit` (`organization_unit_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get()->con->prepare(
|
||||
'INSERT INTO `' . $dbPool->get()->prefix . 'organization_unit` (`organization_unit_name`, `organization_unit_description`, `organization_unit_parent`) VALUES
|
||||
(\'Orange Management\', \'Orange Management\', NULL);'
|
||||
)->execute();
|
||||
break;
|
||||
}
|
||||
UnitMapper::create($unit);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user