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

Commit 858890c

Browse files
committed
Add publishable migration
1 parent 9c477ab commit 858890c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Support\Facades\Schema;
5+
6+
class EnablePostgis extends Migration
7+
{
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::enablePostgisIfNotExists();
16+
}
17+
18+
/**
19+
* Reverse the migrations.
20+
*
21+
* @return void
22+
*/
23+
public function down()
24+
{
25+
Schema::disablePostgisIfExists();
26+
}
27+
}

src/DatabaseServiceProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public function boot()
1313
// Load the config
1414
$config_path = __DIR__ . '/../config/postgis.php';
1515
$this->publishes([$config_path => config_path('postgis.php')], 'postgis');
16+
17+
if (!class_exists('EnablePostgis')) {
18+
$this->publishes([
19+
__DIR__ . '/../database/migrations/enable_postgis.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_enable_postgis.php'),
20+
], 'migrations');
21+
}
22+
1623
$this->mergeConfigFrom($config_path, 'postgis');
1724
}
1825

0 commit comments

Comments
 (0)