riasvdv / statamic-redirect

Redirect allows you to redirect legacy URLs, so that you don't lose SEO value when rebuilding & restructuring a website.
https://statamic.com/addons/rias/redirect
19 stars 21 forks source link

Improve DX using connections. #159

Closed vluijkx closed 8 months ago

vluijkx commented 8 months ago

Hi again! 😅

We need a setup in which errors are kept in the default sqlite store, while redirects are stored in the main Laravel database. Doing this caused all sorts of DX issues which this PR tries to solve.

[!Tip] The DOCUMENTATION.md diff explains how this new setup works.

Issues

There is just one connection config for both errors and redirects.

This meant we had to create our own custom repository to use a seperate connection for redirects. This PR adds seperate redirect_connection and error_connection config values.

The default sqlite database is called errors.sqlite

It took a little while until I realized that eloquent redirects are stored here as well. This PR renames the database to redirect.sqlite.

The README.md is outdated

The repository classes mentioned do not exist anymore. This PR removes outdated and duplicate documentation in the README.md and adds updated documentation to the DOCUMENTATION.md.

The connection name redirect was unclear at first

Renaming it to redirect-sqlite clarified this.

The migration name create_redirect_tables implies that it contains all redirect tables

You need to open the migration files to figure out the difference between:

This PR renames them to:

The different migrations contain clearer tags. This makes it easier for developers to publish just the migration(s) they need.

Considerations

riasvdv commented 8 months ago

Thank you!