-- Documents
CREATE TABLE IF NOT EXISTS `#__eis_documents` (
  `id`         INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `name`       VARCHAR(255) NOT NULL,
  `path`       TEXT         NOT NULL,
  `parent_id`  INT UNSIGNED DEFAULT NULL,
  `is_folder`  TINYINT(1)   NOT NULL DEFAULT 0,
  `title`      VARCHAR(255) DEFAULT NULL,
  `description` TEXT        DEFAULT NULL,
  `ordering`   INT          NOT NULL DEFAULT 0,
  `created`    DATETIME     DEFAULT NULL,
  `modified`   DATETIME     DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_eis_docs_parent`   (`parent_id`),
  KEY `idx_eis_docs_ordering` (`ordering`),
  KEY `idx_eis_docs_name`     (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Settings (Key/Value)
CREATE TABLE IF NOT EXISTS `#__eis_settings` (
  `id`       INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `param`    VARCHAR(191) NOT NULL,
  `value`    TEXT         NULL,
  `created`  DATETIME     DEFAULT NULL,
  `modified` DATETIME     DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_param` (`param`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `#__eis_folder_access` (
  `folder_id` INT UNSIGNED NOT NULL,
  `viewlevel_id` INT UNSIGNED NOT NULL,
  `modified` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`folder_id`),
  KEY `idx_viewlevel` (`viewlevel_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;



-- Standardwert für den PDF-Pfad (leer = noch nicht gesetzt)

INSERT IGNORE INTO `#__eis_settings` (`param`, `value`, `created`, `modified`)
VALUES ('document_root', '/var/www/pdf', NOW(), NOW());