You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+48-2Lines changed: 48 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,11 +50,57 @@ If you are using Laravel < 5.5, you also need to add the DatabaseServiceProvider
50
50
```
51
51
## Usage
52
52
53
-
First of all, make sure to enable postgis.
53
+
To start, ensure you have PostGIS enabled in your database - you can do this in a Laravel migration or manually via SQL.
54
+
55
+
### Enable PostGIS via a Laravel migration
56
+
57
+
Create a new migration file by running
58
+
59
+
php artisan make:migration enable_postgis
60
+
61
+
Update the newly created migration file to call the `enablePostgisIfNotExists()` and `disablePostgisIfExists()` methods on the `Schema` facade. For example:
62
+
63
+
```PHP
64
+
<?php
65
+
66
+
use Illuminate\Database\Migrations\Migration;
67
+
use Illuminate\Support\Facades\Schema;
68
+
69
+
class EnablePostgis extends Migration
70
+
{
71
+
/**
72
+
* Run the migrations.
73
+
*
74
+
* @return void
75
+
*/
76
+
public function up()
77
+
{
78
+
Schema::enablePostgisIfNotExists();
79
+
}
80
+
81
+
/**
82
+
* Reverse the migrations.
83
+
*
84
+
* @return void
85
+
*/
86
+
public function down()
87
+
{
88
+
Schema::disablePostgisIfExists();
89
+
}
90
+
}
91
+
```
92
+
93
+
These methods are safe to use and will only enable / disable the PostGIS extension if relevant - they won't cause an error if PostGIS is / isn't already enabled.
94
+
95
+
If you prefer, you can use the `enablePostgis()` method which will throw an error if PostGIS is already enabled, and the `disablePostgis()` method twhich will throw an error if PostGIS isn't enabled.
96
+
97
+
### Enable PostGIS manually
98
+
99
+
Use an SQL client to connect to your database and run the following command:
0 commit comments