Skip to content

Commit

Permalink
Merge pull request #166 from lukasvelek/sql-database-installation
Browse files Browse the repository at this point in the history
SQL database installation
  • Loading branch information
lukasvelek authored Apr 5, 2024
2 parents 3f558af + 24d451b commit 21f86e3
Show file tree
Hide file tree
Showing 7 changed files with 545 additions and 2 deletions.
97 changes: 97 additions & 0 deletions app/Core/DB/Scripts/database_defaults.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
-- USERS
INSERT INTO `users` (`firstname`, `lastname`, `password`, `username`)
SELECT 'Service', 'User', '$2y$10$Eb34bkiy.Gq/YxkSOyzZYe8egq70wdZTmH56ftMzmGSyBXZFwd9sG', 'service_user'
WHERE NOT EXISTS (SELECT 1 FROM `users` WHERE `username` = 'service_user')

INSERT INTO `users` (`firstname`, `lastname`, `password`, `username`)
SELECT 'Administrator', ' ', '$2y$10$1UNSYh.T5ft0d3HFuyTpJ.i6rIM9DQxoA7Viri1JoyNbWQ15FHVJK', 'admin'
WHERE NOT EXISTS (SELECT 1 FROM `users` WHERE `username` = 'admin')

-- GROUPS
INSERT INTO `groups` (`name`, `code`)
SELECT 'Administrators', 'ADMINISTRATORS'
WHERE NOT EXISTS (SELECT 1 FROM `groups` WHERE `code` = 'ADMINISTRATORS')

INSERT INTO `groups` (`name`, `code`)
SELECT 'Archive Manager', 'ARCHMAN'
WHERE NOT EXISTS (SELECT 1 FROM `groups` WHERE `code` = 'ARCHMAN')

-- METADATA
INSERT INTO `metadata` (`name`, `text`, `table_name`, `is_system`, `input_type`, `length`)
VALUES ('rank', 'Rank', 'documents', '1', 'select', '256')

INSERT INTO `metadata` (`name`, `text`, `table_name`, `is_system`, `input_type`, `length`)
VALUES ('status', 'Status', 'documents', '1', 'select', '256')

INSERT INTO `metadata` (`name`, `text`, `table_name`, `is_system`, `input_type`, `length`)
VALUES ('after_shred_action', 'Action after shredding', 'documents', '1', 'select', '256')

INSERT INTO `metadata` (`name`, `text`, `table_name`, `is_system`, `input_type`, `length`)
VALUES ('shredding_status', 'Shredding status', 'documents', '1', 'select', '256')

INSERT INTO `metadata` (`name`, `text`, `table_name`, `is_system`, `input_type`, `length`)
VALUES ('status', 'Status', 'users', '1', 'select', '256')

INSERT INTO `metadata` (`name`, `text`, `table_name`, `is_system`, `input_type`, `length`)
VALUES ('status', 'Status', 'processes', '1', 'select', '256')

INSERT INTO `metadata` (`name`, `text`, `table_name`, `is_system`, `input_type`, `length`)
VALUES ('type', 'Type', 'processes', '1', 'select', '256')

INSERT INTO `metadata` (`name`, `text`, `table_name`, `is_system`, `input_type`, `length`)
VALUES ('status', 'Status', 'archive', '1', 'select', '256')

INSERT INTO `metadata` (`name`, `text`, `table_name`, `is_system`, `input_type`, `length`)
VALUES ('type', 'Type', 'archive', '1', 'select', '256')

-- SERVICE CONFIG
INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('LogRotateService', 'files_keep_length', '7')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('LogRotateService', 'service_run_period', '7')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('LogRotateService', 'archive_old_logs', '1')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('PasswordPolicyService', 'password_change_period', '30')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('PasswordPolicyService', 'password_change_force_administrators', '0')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('PasswordPolicyService', 'password_change_force', '0')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('PasswordPolicyService', 'service_run_period', '30')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('NotificationManagerService', 'notification_keep_length', '1')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('NotificationManagerService', 'service_run_period', '7')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('NotificationManagerService', 'notification_keep_unseen_service_user', '1')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('CacheRotateService', 'service_run_period', '1')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('FileManagerService', 'service_run_period', '30')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('ShreddingSuggestionService', 'service_run_period', '30')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('MailService', 'service_run_period', '1')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('DocumentArchivationService', 'service_run_period', '7')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('DeclinedDocumentRemoverService', 'service_run_period', '30')

INSERT INTO `service_config` (`name`, `key`, `value`)
VALUES ('DocumentReportGeneratorService', 'service_run_period', '1')
29 changes: 29 additions & 0 deletions app/Core/DB/Scripts/database_indexes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE INDEX `documents_1` ON `documents` (id_folder)
CREATE INDEX `documents_2` ON `documents` (status)
CREATE INDEX `document_comments_1` ON `document_comments` (id_document)
CREATE INDEX `document_sharing_1` ON `document_sharing` (id_user, id_document)
CREATE INDEX `document_filters_1` ON `document_filters` (id_author)
CREATE INDEX `document_reports_1` ON `document_reports` (id_user)
CREATE INDEX `user_bulk_rights_1` ON `user_bulk_rights` (id_user)
CREATE INDEX `user_action_rights_1` ON `user_action_rights` (id_user)
CREATE INDEX `user_metadata_rights_1` ON `user_metadata_rights` (id_user, id_metadata)
CREATE INDEX `ribbon_user_rights_1` ON `ribbon_user_rights` (id_ribbon, id_user)
CREATE INDEX `group_bulk_rights_1` ON `group_bulk_rights` (id_group)
CREATE INDEX `group_action_rights_1` ON `group_action_rights` (id_group)
CREATE INDEX `group_metadata_rights_1` ON `group_metadata_rights` (id_group, id_metadata)
CREATE INDEX `ribbon_group_rights_1` ON `ribbon_group_rights` (id_ribbon, id_group)
CREATE INDEX `metadata_values_1` ON `metadata_values` (id_metadata)
CREATE INDEX `folders_1` ON `folders` (id_parent_folder)
CREATE INDEX `processes_1` ON `processes` (id_document)
CREATE INDEX `processes_2` ON `processes` (id_author)
CREATE INDEX `processes_3` ON `processes` (workflow1, workflow2, workflow3, workflow4)
CREATE INDEX `process_comments_1` ON `process_comments` (id_process)
CREATE INDEX `notifications_1` ON `notifications` (id_user)
CREATE INDEX `password_reset_hashes_1` ON `password_reset_hashes` (id_user)
CREATE INDEX `ribbons_1` ON `ribbons` (id_parent_ribbon)
CREATE INDEX `file_storage_locations_1` ON `file_storage_locations` (type)
CREATE INDEX `file_storage_locations_2` ON `file_storage_locations` (name)
CREATE INDEX `services_1` ON `services` (system_name)
CREATE INDEX `users_1` ON `users` (last_login_hash)
CREATE INDEX `document_metadata_history_1` ON `document_metadata_history` (id_document)
CREATE INDEX `document_locks_1` ON `document_locks` (id_document, status)
29 changes: 29 additions & 0 deletions app/Core/DB/Scripts/database_services.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('LogRotateService', 'Log rotate', 'Deletes old log files', '1', '1')

INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('CacheRotateService', 'Cache rotate', 'Deletes old cache files', '1', '1')

INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('FileManagerService', 'File manager', 'Deletes old unused files', '1', '1')

INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('ShreddingSuggestionService', 'Shredding suggestion', 'Suggests documents for shredding', '1', '1')

INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('PasswordPolicyService', 'Password policy', 'Checks if passwords have been changed in a period of time', '1', '1')

INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('MailService', 'Mail service', 'Service responsible for sending emails', '1', '1')

INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('NotificationManagerService', 'Notification manager', 'Service responsible for deleting old notifications', '1', '1')

INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('DocumentArchivationService', 'Document archivator', 'Archives documents waiting for archivation', '1', '1')

INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('DeclinedDocumentRemoverService', 'Declined document remover', 'Deletes declined documents', '1', '1')

INSERT INTO `services` (`system_name`, `display_name`, `description`, `is_enabled`, `is_system`)
VALUES ('DocumentReportGeneratorService', 'Document report generator', 'Generates document reports', '1', '1')
Loading

0 comments on commit 21f86e3

Please sign in to comment.