This repository was archived by the owner on Oct 1, 2024. It is now read-only.
Add methods to enable / disable PostGIS only if relevant #152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed there are already methods for enabling (
enablePostgis()
) and disabling (disablePostgis()
) PostGIS via a migration, but these throw an error if PostGIS is already enabled / disabled.With the introduction of parallel testing in Laravel 8.25 the framework may create a new database for tests - therefore the enabling of PostGIS needs to be in a migration.
While the existing
enablePostgis()
method would work on the first run of the test suite, it causes an error on subsequent runs as the PostGIS extension is already enabled in the database.Whilst this could be solved by using the
--recreate-databases
flag on each run of this test suite, I think it would be better to add methods to this package to handle this through the use ofIF EXISTS
andIF NOT EXISTS
parameters. They maybe useful for other use cases too.This PR adds two new methods,
enablePostgisIfNotExists()
anddisablePostgisIfExists()
and the relevant tests.I've also updated the README - it already had instructions for manually enabling PostGIS, so I've added to it to cover using the new & old methods (which were undocumented) in a migration.