mirror of
https://github.com/Karaka-Management/oms-Editor.git
synced 2026-02-12 16:28:42 +00:00
Move schema to json
This commit is contained in:
parent
ad81380402
commit
b3949f5d8b
46
Admin/Install/db.json
Normal file
46
Admin/Install/db.json
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
"editor_doc": {
|
||||||
|
"name": "editor_doc",
|
||||||
|
"fields": {
|
||||||
|
"editor_doc_id": {
|
||||||
|
"name": "editor_doc_id",
|
||||||
|
"type": "INT",
|
||||||
|
"null": false,
|
||||||
|
"primary": true,
|
||||||
|
"autoincrement": true
|
||||||
|
},
|
||||||
|
"editor_doc_title": {
|
||||||
|
"name": "editor_doc_title",
|
||||||
|
"type": "VARCHAR(255)",
|
||||||
|
"null": false
|
||||||
|
},
|
||||||
|
"editor_doc_plain": {
|
||||||
|
"name": "editor_doc_plain",
|
||||||
|
"type": "TEXT",
|
||||||
|
"null": false
|
||||||
|
},
|
||||||
|
"editor_doc_content": {
|
||||||
|
"name": "editor_doc_content",
|
||||||
|
"type": "TEXT",
|
||||||
|
"null": false
|
||||||
|
},
|
||||||
|
"editor_doc_path": {
|
||||||
|
"name": "editor_doc_path",
|
||||||
|
"type": "VARCHAR(255)",
|
||||||
|
"null": false
|
||||||
|
},
|
||||||
|
"editor_doc_created_by": {
|
||||||
|
"name": "editor_doc_created_by",
|
||||||
|
"type": "INT",
|
||||||
|
"null": false,
|
||||||
|
"foreignTable": "account",
|
||||||
|
"foreignKey": "account_id"
|
||||||
|
},
|
||||||
|
"editor_doc_created_at": {
|
||||||
|
"name": "editor_doc_created_at",
|
||||||
|
"type": "DATETIME",
|
||||||
|
"null": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,9 +14,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Editor\Admin;
|
namespace Modules\Editor\Admin;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\DatabasePool;
|
|
||||||
use phpOMS\DataStorage\Database\DatabaseType;
|
|
||||||
use phpOMS\Module\InfoManager;
|
|
||||||
use phpOMS\Module\InstallerAbstract;
|
use phpOMS\Module\InstallerAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -29,50 +26,4 @@ use phpOMS\Module\InstallerAbstract;
|
||||||
*/
|
*/
|
||||||
class Installer extends 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 . 'editor_doc` (
|
|
||||||
`editor_doc_id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`editor_doc_title` varchar(250) NOT NULL,
|
|
||||||
`editor_doc_plain` text NOT NULL,
|
|
||||||
`editor_doc_content` text NOT NULL,
|
|
||||||
`editor_doc_path` varchar(255) NOT NULL,
|
|
||||||
`editor_doc_created_at` datetime NOT NULL,
|
|
||||||
`editor_doc_created_by` int(11) NOT NULL,
|
|
||||||
PRIMARY KEY (`editor_doc_id`),
|
|
||||||
KEY `editor_doc_created_by` (`editor_doc_created_by`)
|
|
||||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
|
||||||
)->execute();
|
|
||||||
|
|
||||||
$dbPool->get()->con->prepare(
|
|
||||||
'ALTER TABLE `' . $dbPool->get()->prefix . 'editor_doc`
|
|
||||||
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'editor_doc_ibfk_1` FOREIGN KEY (`editor_doc_created_by`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);'
|
|
||||||
)->execute();
|
|
||||||
|
|
||||||
$dbPool->get()->con->prepare(
|
|
||||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'editor_tag` (
|
|
||||||
`editor_tag_id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`editor_tag_doc` int(11) NOT NULL,
|
|
||||||
`editor_tag_tag` varchar(20) NOT NULL,
|
|
||||||
PRIMARY KEY (`editor_tag_id`),
|
|
||||||
KEY `editor_tag_doc` (`editor_tag_doc`)
|
|
||||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
|
||||||
)->execute();
|
|
||||||
|
|
||||||
$dbPool->get()->con->prepare(
|
|
||||||
'ALTER TABLE `' . $dbPool->get()->prefix . 'editor_tag`
|
|
||||||
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'editor_tag_ibfk_1` FOREIGN KEY (`editor_tag_doc`) REFERENCES `' . $dbPool->get()->prefix . 'editor_doc` (`editor_doc_id`);'
|
|
||||||
)->execute();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user