diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-07-23 21:56:01 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2014-07-23 21:58:19 +0200 |
commit | cc72236f71c60396b69631656f8e0ad00a6301c8 (patch) | |
tree | a981833a17cba56e85682048a84e544e877af773 /application/controllers/tools.php | |
parent | ce58ad70b8f3800adeaaadd46d8ed499bc21eda6 (diff) |
Move migration code to CLI callable function
This is necessary to prevent migrations from running multiple times in
parallel. A git hook can be used to run this after checkout so impact
should be fairly low.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/tools.php')
-rw-r--r-- | application/controllers/tools.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/application/controllers/tools.php b/application/controllers/tools.php new file mode 100644 index 000000000..b80dc5024 --- /dev/null +++ b/application/controllers/tools.php @@ -0,0 +1,45 @@ +<?php +/* + * Copyright 2014 Florian "Bluewind" Pritz <bluewind@server-speed.net> + * + * Licensed under AGPLv3 + * (see COPYING for full license text) + * + */ + +class Tools extends MY_Controller { + + function __construct() + { + parent::__construct(); + + $this->load->model('mfile'); + if (!$this->input->is_cli_request()) { + show_error("This can only be called via CLI"); + } + } + + function index() + { + echo "php index.php <controller> <function> [arguments]\n"; + echo "\n"; + echo "Functions:\n"; + echo " file cron Cronjob\n"; + echo " file nuke_id <ID> Nukes all IDs sharing the same hash\n"; + echo " user cron Cronjob\n"; + echo " tools update_database Update/Initialise the database\n"; + echo "\n"; + echo "Functions that shouldn't have to be run:\n"; + echo " file clean_stale_files Remove files without database entries\n"; + echo " file update_file_metadata Update filesize and mimetype in database\n"; + exit; + } + + function update_database() + { + $this->load->library('migration'); + if ( ! $this->migration->current()) { + show_error($this->migration->error_string()); + } + } +} |