Skip to content

Commit 5be106f

Browse files
committed
Update README with easier migrations installation
1 parent 858890c commit 5be106f

File tree

1 file changed

+8
-32
lines changed

1 file changed

+8
-32
lines changed

README.md

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -54,45 +54,21 @@ To start, ensure you have PostGIS enabled in your database - you can do this in
5454

5555
### Enable PostGIS via a Laravel migration
5656

57-
Create a new migration file by running
57+
You need to publish the migration to easily enable PostGIS:
5858

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;
59+
```sh
60+
php artisan vendor:publish --provider="MStaack\LaravelPostgis\DatabaseServiceProvider" --tag="migrations"
61+
```
6862

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-
}
63+
And then you run the migrations:
8064

81-
/**
82-
* Reverse the migrations.
83-
*
84-
* @return void
85-
*/
86-
public function down()
87-
{
88-
Schema::disablePostgisIfExists();
89-
}
90-
}
65+
```sh
66+
php artisan migrate
9167
```
9268

9369
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.
9470

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.
71+
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.
9672

9773
### Enable PostGIS manually
9874

0 commit comments

Comments
 (0)