Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Conversation

gbuckingham89
Copy link
Contributor

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 of IF EXISTS and IF NOT EXISTS parameters. They maybe useful for other use cases too.

This PR adds two new methods, enablePostgisIfNotExists() and disablePostgisIfExists() 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.

Copy link
Owner

@mstaack mstaack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thank you.

@mstaack mstaack merged commit 9c477ab into mstaack:master Jan 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants