Skip to content

Commit

Permalink
Merge branch '1.2' of github.com:wintercms/docs into 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Jul 19, 2024
2 parents 80f0763 + 2b84f6c commit 9395ca4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions database/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ Schema::table('users', function ($table) {
});
```

You can also use the `dropColumnIfExists` method on the Schema builder for a slightly safer way of handling migrations:

```php
Schema::table('users', function ($table) {
$table->dropColumnIfExists('single_column');
// or
$table->dropColumnIfExists('one_column', 'two_column');
// or
$table->dropColumnIfExists([
'one_column',
'two_column',
'red_column',
'blue_column',
]);
}
```

### Creating indexes

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:
Expand Down

0 comments on commit 9395ca4

Please sign in to comment.