-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/UpdateScripts/AddDescriptionColumnToRedirectsTable.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Rias\StatamicRedirect\UpdateScripts; | ||
|
||
use Illuminate\Database\QueryException; | ||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\Facades\Schema; | ||
use Statamic\UpdateScripts\UpdateScript; | ||
|
||
class AddDescriptionColumnToRedirectsTable extends UpdateScript | ||
{ | ||
public function shouldUpdate($newVersion, $oldVersion) | ||
{ | ||
if (config('statamic.redirect.redirect_connection') === 'stache') { | ||
return false; | ||
} | ||
|
||
try { | ||
return ! Schema::connection(config('statamic.redirect.redirect_connection'))->hasColumn('redirects', 'description'); | ||
} catch (QueryException) { | ||
// Query exception happens when database is not set up | ||
return false; | ||
} | ||
} | ||
|
||
public function update() | ||
{ | ||
Artisan::call('vendor:publish', [ | ||
'--tag' => 'statamic-redirect-redirect-migrations' | ||
]); | ||
|
||
$this->console()->info('New migration for Redirect description published, make sure to it!'); | ||
} | ||
} |