You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: migrations.md
+11-7Lines changed: 11 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -267,7 +267,7 @@ When creating the table, you may use any of the schema builder's [column methods
267
267
<aname="determining-table-column-existence"></a>
268
268
#### Determining Table / Column Existence
269
269
270
-
You may determine the existence of a tableor column using the `hasTable`and `hasColumn` methods:
270
+
You may determine the existence of a table, column, or index using the `hasTable`, `hasColumn`, and `hasIndex` methods:
271
271
272
272
if (Schema::hasTable('users')) {
273
273
// The "users" table exists...
@@ -277,6 +277,10 @@ You may determine the existence of a table or column using the `hasTable` and `h
277
277
// The "users" table exists and has an "email" column...
278
278
}
279
279
280
+
if (Schema::hasIndex('users', ['email'], 'unique')) {
281
+
// The "users" table exists and has a unique index on the "email" column...
282
+
}
283
+
280
284
<aname="database-connection-table-options"></a>
281
285
#### Database Connection and Table Options
282
286
@@ -289,16 +293,16 @@ If you want to perform a schema operation on a database connection that is not y
289
293
In addition, a few other properties and methods may be used to define other aspects of the table's creation. The `engine` property may be used to specify the table's storage engine when using MySQL:
290
294
291
295
Schema::create('users', function (Blueprint $table) {
292
-
$table->engine = 'InnoDB';
296
+
$table->engine('InnoDB');
293
297
294
298
// ...
295
299
});
296
300
297
301
The `charset` and `collation` properties may be used to specify the character set and collation for the created table when using MySQL:
298
302
299
303
Schema::create('users', function (Blueprint $table) {
300
-
$table->charset = 'utf8mb4';
301
-
$table->collation = 'utf8mb4_unicode_ci';
304
+
$table->charset('utf8mb4');
305
+
$table->collation('utf8mb4_unicode_ci');
302
306
303
307
// ...
304
308
});
@@ -941,7 +945,7 @@ Modifier | Description
941
945
`->autoIncrement()` | Set INTEGER columns as auto-incrementing (primary key).
942
946
`->charset('utf8mb4')` | Specify a character set for the column (MySQL).
943
947
`->collation('utf8mb4_unicode_ci')` | Specify a collation for the column.
944
-
`->comment('my comment')` | Add a comment to a column (MySQL/PostgreSQL).
948
+
`->comment('my comment')` | Add a comment to a column (MySQL / PostgreSQL).
945
949
`->default($value)` | Specify a "default" value for the column.
946
950
`->first()` | Place the column "first" in the table (MySQL).
947
951
`->from($integer)` | Set the starting value of an auto-incrementing field (MySQL / PostgreSQL).
@@ -951,7 +955,7 @@ Modifier | Description
951
955
`->unsigned()` | Set INTEGER columns as UNSIGNED (MySQL).
952
956
`->useCurrent()` | Set TIMESTAMP columns to use CURRENT_TIMESTAMP as default value.
953
957
`->useCurrentOnUpdate()` | Set TIMESTAMP columns to use CURRENT_TIMESTAMP when a record is updated (MySQL).
Copy file name to clipboardExpand all lines: releases.md
+15Lines changed: 15 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -351,3 +351,18 @@ Laravel 11 includes improved support for MariaDB. In previous Laravel releases,
351
351
352
352
For more information on Laravel's database drivers, check out the [database documentation](/docs/{{version}}/database).
353
353
354
+
<aname="inspecting-database"></a>
355
+
### Inspecting Databases and Improved Schema Operations
356
+
357
+
_Improved schema operations and database inspection was contributed by [Hafez Divandari](https://github.com/hafezdivandari)_
358
+
359
+
Laravel 11 provides additional database schema operation and inspection methods, including the native modifying, renaming, and dropping of columns. Furthermore, advanced spatial types, non-default schema names, and native schema methods for manipulating tables, views, columns, indexes, and foreign keys are provided:
0 commit comments