Skip to content

Commit 9395ca4

Browse files
committed
Merge branch '1.2' of github.com:wintercms/docs into 1.2
2 parents 80f0763 + 2b84f6c commit 9395ca4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

database/structure.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,23 @@ Schema::table('users', function ($table) {
217217
});
218218
```
219219

220+
You can also use the `dropColumnIfExists` method on the Schema builder for a slightly safer way of handling migrations:
221+
222+
```php
223+
Schema::table('users', function ($table) {
224+
$table->dropColumnIfExists('single_column');
225+
// or
226+
$table->dropColumnIfExists('one_column', 'two_column');
227+
// or
228+
$table->dropColumnIfExists([
229+
'one_column',
230+
'two_column',
231+
'red_column',
232+
'blue_column',
233+
]);
234+
}
235+
```
236+
220237
### Creating indexes
221238

222239
The schema builder supports several types of indexes. First, let's look at an example that specifies a column's values should be unique. To create the index, we can simply chain the `unique` method onto the column definition:

0 commit comments

Comments
 (0)