diff --git a/README.md b/README.md index 93aa35d7..1f6b8936 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,7 @@ Follow this steps: - Restore your `.env` config file on your server. ## Update from 1.7.8 to 1.7.9 -After uploaded new files, log in as admin to the app and go to `your-domain.com/upgrade-database`. This will upgrade your database on the background. +After uploaded new files, log in as admin to the app and go to `your-domain.com/service/upgrade-database`. This will upgrade your database on the background. After that, **update path to your project in command below** and add the following **Cron** entry to your server: ``` diff --git a/app/Http/Controllers/General/UpgradeAppController.php b/app/Http/Controllers/General/UpgradeAppController.php index 75d18958..504d4118 100644 --- a/app/Http/Controllers/General/UpgradeAppController.php +++ b/app/Http/Controllers/General/UpgradeAppController.php @@ -125,6 +125,28 @@ class UpgradeAppController extends Controller return response('Done', 200); } + /** + * Start maintenance mode + */ + public function up() { + $command = Artisan::call('up'); + + if ($command === 0) { + echo 'System is in production mode'; + } + } + + /** + * End maintenance mode + */ + public function down() { + $command = Artisan::call('down'); + + if ($command === 0) { + echo 'System is in maintenance mode'; + } + } + /** * Upgrade database */ @@ -137,7 +159,9 @@ class UpgradeAppController extends Controller */ if (! Schema::hasColumn('shares', 'expire_in')) { - $command = Artisan::call('migrate'); + $command = Artisan::call('migrate', [ + '--force' => true + ]); if ($command === 0) { echo 'Operation was successful.'; diff --git a/app/Http/Middleware/CheckForMaintenanceMode.php b/app/Http/Middleware/CheckForMaintenanceMode.php index 35b9824b..f5934820 100644 --- a/app/Http/Middleware/CheckForMaintenanceMode.php +++ b/app/Http/Middleware/CheckForMaintenanceMode.php @@ -12,6 +12,8 @@ class CheckForMaintenanceMode extends Middleware * @var array */ protected $except = [ - // + '/service/upgrade-database', + '/service/down', + '/service/up', ]; } diff --git a/routes/web.php b/routes/web.php index 7b7d600f..fd507f4a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -38,8 +38,10 @@ Route::group(['middleware' => ['auth:api', 'auth.master', 'scope:master']], func }); // Admin system tools -Route::group(['middleware' => ['auth:api', 'auth.master', 'auth.admin', 'scope:master']], function () { +Route::group(['middleware' => ['auth:api', 'auth.master', 'auth.admin', 'scope:master'], 'prefix' => 'service'], function () { Route::get('/upgrade-database', 'General\UpgradeAppController@upgrade_database'); + Route::get('/down', 'General\UpgradeAppController@down'); + Route::get('/up', 'General\UpgradeAppController@up'); }); // Get og site for web crawlers