2222use Rias \StatamicRedirect \UpdateScripts \AddDescriptionColumnToRedirectsTable ;
2323use Rias \StatamicRedirect \UpdateScripts \AddHitsCount ;
2424use Rias \StatamicRedirect \UpdateScripts \ClearErrors ;
25+ use Rias \StatamicRedirect \UpdateScripts \IncreaseUrlSizeOnErrors ;
26+ use Rias \StatamicRedirect \UpdateScripts \IncreaseUrlSizeOnRedirects ;
2527use Rias \StatamicRedirect \UpdateScripts \MoveRedirectsToDefaultSite ;
2628use Rias \StatamicRedirect \UpdateScripts \RenameLocaleToSiteOnRedirectsTable ;
2729use Rias \StatamicRedirect \Widgets \ErrorsLastDayWidget ;
@@ -45,14 +47,16 @@ class RedirectServiceProvider extends AddonServiceProvider
4547 MoveRedirectsToDefaultSite::class,
4648 RenameLocaleToSiteOnRedirectsTable::class,
4749 AddDescriptionColumnToRedirectsTable::class,
50+ IncreaseUrlSizeOnRedirects::class,
51+ IncreaseUrlSizeOnErrors::class,
4852 ];
4953
5054 protected $ scripts = [
51- __DIR__ . '/../resources/dist/js/cp.js ' ,
55+ __DIR__ . '/../resources/dist/js/cp.js ' ,
5256 ];
5357
5458 protected $ routes = [
55- 'cp ' => __DIR__ . '/../routes/cp.php ' ,
59+ 'cp ' => __DIR__ . '/../routes/cp.php ' ,
5660 ];
5761
5862 protected $ listen = [
@@ -112,17 +116,19 @@ public function boot()
112116 ->bootPermissions ();
113117 });
114118
115- if (! $ this ->app ->runningInConsole ()) {
119+ if (!$ this ->app ->runningInConsole ()) {
116120 return ;
117121 }
118122
119123 $ this ->publishes ([
120124 __DIR__ . '/../database/migrations/create_redirect_error_tables.php.stub ' => database_path ('migrations/ ' . date ('Y_m_d_His ' , time ()) . '_create_redirect_error_tables.php ' ),
125+ __DIR__ . '/../database/migrations/increase_redirect_error_table_url_length.php.stub ' => database_path ('migrations/ ' . date ('Y_m_d_His ' , time () + 1 ) . '_increase_redirect_error_table_url_length.php ' ),
121126 ], 'statamic-redirect-error-migrations ' );
122127
123128 $ this ->publishes ([
124129 __DIR__ . '/../database/migrations/create_redirect_redirects_table.php.stub ' => database_path ('migrations/ ' . date ('Y_m_d_His ' , time ()) . '_create_redirect_redirects_table.php ' ),
125- __DIR__ . '/../database/migrations/add_description_to_redirect_redirects_table.php.stub ' => database_path ('migrations/ ' . date ('Y_m_d_His ' , time ()) . '_add_description_to_redirect_redirects_table.php ' ),
130+ __DIR__ . '/../database/migrations/add_description_to_redirect_redirects_table.php.stub ' => database_path ('migrations/ ' . date ('Y_m_d_His ' , time () + 1 ) . '_add_description_to_redirect_redirects_table.php ' ),
131+ __DIR__ . '/../database/migrations/increase_redirect_redirects_table_url_length.php.stub ' => database_path ('migrations/ ' . date ('Y_m_d_His ' , time () + 2 ) . '_increase_redirect_redirects_table_url_length.php ' ),
126132 ], 'statamic-redirect-redirect-migrations ' );
127133 }
128134
@@ -141,7 +147,7 @@ protected function getRedirectRepository()
141147
142148 protected function bootAddonViews ()
143149 {
144- $ this ->loadViewsFrom (__DIR__ . '/../resources/views ' , 'redirect ' );
150+ $ this ->loadViewsFrom (__DIR__ . '/../resources/views ' , 'redirect ' );
145151
146152 return $ this ;
147153 }
@@ -160,8 +166,8 @@ protected function bootAddonNav()
160166 $ nav ->tools ('Redirect ' )
161167 ->route (
162168 config ('statamic.redirect.log_errors ' )
163- ? 'redirect.index '
164- : 'redirect.redirects.index '
169+ ? 'redirect.index '
170+ : 'redirect.redirects.index '
165171 )
166172 ->icon ('git ' )
167173 ->active ('redirect ' )
@@ -183,7 +189,7 @@ protected function bootStores()
183189
184190 protected function bootDatabase ()
185191 {
186- if (! config ('statamic.redirect.log_errors ' )) {
192+ if (!config ('statamic.redirect.log_errors ' )) {
187193 return $ this ;
188194 }
189195
@@ -207,17 +213,17 @@ protected function ensureDatabaseExists($sqlitePath)
207213 {
208214 $ oldSqlitePath = storage_path ('redirect/errors.sqlite ' );
209215
210- if (! file_exists ($ sqlitePath ) && file_exists ($ oldSqlitePath )) {
216+ if (!file_exists ($ sqlitePath ) && file_exists ($ oldSqlitePath )) {
211217 File::move ($ oldSqlitePath , $ sqlitePath );
212218
213219 return ;
214220 }
215221
216- if (! file_exists ($ sqlitePath )) {
222+ if (!file_exists ($ sqlitePath )) {
217223 File::put ($ sqlitePath , '' );
218224
219225 $ gitIgnorePath = storage_path ('redirect/.gitignore ' );
220- if (! file_exists ($ gitIgnorePath )) {
226+ if (!file_exists ($ gitIgnorePath )) {
221227 File::put ($ gitIgnorePath , "* \n!.gitignore " );
222228 }
223229 }
@@ -227,7 +233,7 @@ protected function bootDatabaseForErrors()
227233 {
228234 if (
229235 config ('statamic.redirect.error_connection ' , 'redirect-sqlite ' ) !== 'redirect-sqlite ' &&
230- ! $ this ->generalConnectionIsBuiltinSqlite ()
236+ !$ this ->generalConnectionIsBuiltinSqlite ()
231237 ) {
232238 return ;
233239 }
@@ -240,14 +246,16 @@ protected function bootDatabaseForErrors()
240246 DB ::setDefaultConnection ('redirect-sqlite ' );
241247 require_once (__DIR__ . '/../database/migrations/create_redirect_error_tables.php.stub ' );
242248 (new \CreateRedirectErrorTables ())->up ();
249+ require_once (__DIR__ . '/../database/migrations/increase_redirect_error_table_url_length.php.stub ' );
250+ (new \IncreaseRedirectErrorTableUrlLength ())->up ();
243251 DB ::setDefaultConnection ($ defaultConnection );
244252 }
245253
246254 protected function bootDatabaseForRedirects ()
247255 {
248256 if (
249257 config ('statamic.redirect.redirect_connection ' , 'stache ' ) !== 'redirect-sqlite ' &&
250- ! $ this ->generalConnectionIsBuiltinSqlite ()
258+ !$ this ->generalConnectionIsBuiltinSqlite ()
251259 ) {
252260 return ;
253261 }
@@ -263,6 +271,8 @@ protected function bootDatabaseForRedirects()
263271 (new \CreateRedirectRedirectsTable ())->up ();
264272 require_once (__DIR__ . '/../database/migrations/add_description_to_redirect_redirects_table.php.stub ' );
265273 (new \AddDescriptionToRedirectRedirectsTable ())->up ();
274+ require_once (__DIR__ . '/../database/migrations/increase_redirect_redirects_table_url_length.php.stub ' );
275+ (new \IncreaseRedirectRedirectsTableUrlLength ())->up ();
266276
267277 DB ::setDefaultConnection ($ defaultConnection );
268278 }
@@ -282,10 +292,10 @@ protected function generalConnectionIsBuiltinSqlite()
282292
283293 protected function registerAddonConfig ()
284294 {
285- $ this ->mergeConfigFrom (__DIR__ . '/../config/redirect.php ' , 'statamic.redirect ' );
295+ $ this ->mergeConfigFrom (__DIR__ . '/../config/redirect.php ' , 'statamic.redirect ' );
286296
287297 $ this ->publishes ([
288- __DIR__ . '/../config/redirect.php ' => config_path ('statamic/redirect.php ' ),
298+ __DIR__ . '/../config/redirect.php ' => config_path ('statamic/redirect.php ' ),
289299 ], 'statamic-redirect-config ' );
290300
291301 return $ this ;
0 commit comments