File tree 5 files changed +53
-0
lines changed
5 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -148,4 +148,15 @@ public function disablePostgis()
148
148
return $ this ->addCommand ('disablePostgis ' );
149
149
}
150
150
151
+ /**
152
+ * Disable postgis on this database.
153
+ * WIll drop the extension in the database if it exists.
154
+ *
155
+ * @return \Illuminate\Support\Fluent
156
+ */
157
+ public function disablePostgisIfExists ()
158
+ {
159
+ return $ this ->addCommand ('disablePostgisIfExists ' );
160
+ }
161
+
151
162
}
Original file line number Diff line number Diff line change @@ -54,4 +54,17 @@ public function disablePostgis()
54
54
$ this ->grammar ->compileDisablePostgis ()
55
55
);
56
56
}
57
+
58
+ /**
59
+ * Disable postgis on this database.
60
+ * WIll drop the extension in the database if it exists.
61
+ *
62
+ * @return bool
63
+ */
64
+ public function disablePostgisIfExists ()
65
+ {
66
+ return $ this ->connection ->statement (
67
+ $ this ->grammar ->compileDisablePostgisIfExists ()
68
+ );
69
+ }
57
70
}
Original file line number Diff line number Diff line change @@ -153,6 +153,16 @@ public function compileDisablePostgis()
153
153
return 'DROP EXTENSION postgis ' ;
154
154
}
155
155
156
+ /**
157
+ * Adds a statement to drop the postgis extension, if it exists
158
+ *
159
+ * @return string
160
+ */
161
+ public function compileDisablePostgisIfExists ()
162
+ {
163
+ return 'DROP EXTENSION IF EXISTS postgis ' ;
164
+ }
165
+
156
166
/**
157
167
* Adds a statement to add a geometry column
158
168
*
Original file line number Diff line number Diff line change @@ -107,4 +107,13 @@ public function testDisablePostgis()
107
107
108
108
$ this ->blueprint ->disablePostgis ();
109
109
}
110
+
111
+ public function testDisablePostgisIfExists ()
112
+ {
113
+ $ this ->blueprint
114
+ ->shouldReceive ('addCommand ' )
115
+ ->with ('disablePostgis ' , []);
116
+
117
+ $ this ->blueprint ->disablePostgisIfExists ();
118
+ }
110
119
}
Original file line number Diff line number Diff line change @@ -294,6 +294,16 @@ public function testDisablePostgis()
294
294
$ this ->assertStringContainsString ('DROP EXTENSION postgis ' , $ statements [0 ]);
295
295
}
296
296
297
+ public function testDisablePostgisIfExists ()
298
+ {
299
+ $ blueprint = new Blueprint ('test ' );
300
+ $ blueprint ->disablePostgisIfExists ();
301
+ $ statements = $ blueprint ->toSql ($ this ->getConnection (), $ this ->getGrammar ());
302
+
303
+ $ this ->assertCount (1 , $ statements );;
304
+ $ this ->assertStringContainsString ('DROP EXTENSION IF EXISTS postgis ' , $ statements [0 ]);
305
+ }
306
+
297
307
/**
298
308
* @return Connection
299
309
*/
You can’t perform that action at this time.
0 commit comments