From 4115d33e3e63ea04b1dfdf907d2ebb727b0bfddc Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Wed, 31 Jan 2024 22:24:54 +0330 Subject: [PATCH 1/2] add a note for index modifiers --- migrations.md | 9 ++++++++- upgrade.md | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/migrations.md b/migrations.md index a58ee60f938..33330d43345 100644 --- a/migrations.md +++ b/migrations.md @@ -983,12 +983,19 @@ The `change` method allows you to modify the type and attributes of existing col $table->string('name', 50)->change(); }); -When modifying a column, you must explicitly include all of the modifiers you want to keep on the column definition - any missing attribute will be dropped. For example, to retain the `unsigned`, `default`, and `comment` attributes, you must call each modifier explicitly when changing the column: +When modifying a column, you must explicitly include all the modifiers you want to keep on the column definition - any missing attribute will be dropped. For example, to retain the `unsigned`, `default`, and `comment` attributes, you must call each modifier explicitly when changing the column: Schema::table('users', function (Blueprint $table) { $table->integer('votes')->unsigned()->default(1)->comment('my comment')->change(); }); +The `change` method does not change indexes of the column. Therefore, you may use index modifiers explicitly to add/drop an index when modifying the column: + +```php +$table->bigIncrements('id')->primary()->change(); +$table->char('postal_code', 10)->unique(false)->change(); +``` + ### Renaming Columns diff --git a/upgrade.md b/upgrade.md index bd88ba88ced..cf68b5e4f19 100644 --- a/upgrade.md +++ b/upgrade.md @@ -101,6 +101,13 @@ Schema::table('users', function (Blueprint $table) { }); ``` +The `change` method does not change indexes of the column. Therefore, you may use index modifiers explicitly to add/drop an index when modifying the column: + +```php +$table->bigIncrements('id')->primary()->change(); +$table->char('postal_code', 10)->unique(false)->change(); +``` + #### Floating-Point Types @@ -140,7 +147,7 @@ $table->geometry('shapes'); $table->geography('coordinates'); ``` -To explicitly restrict the type or the spatial reference system identifier for values stored in the column on MySQL and PostgreSQL, you may pass the `subtype` and `srid` to the method: +To explicitly restrict the type or the spatial reference system identifier for values stored in the column on MySQL, MariaDB, and PostgreSQL, you may pass the `subtype` and `srid` to the method: ```php $table->geometry('dimension', subtype: 'polygon', srid: 0); From 93d8caf6b1743d2620623b0e7625b5db93727070 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 31 Jan 2024 14:15:26 -0600 Subject: [PATCH 2/2] formatting --- migrations.md | 5 ++++- upgrade.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/migrations.md b/migrations.md index 33330d43345..8b71734933e 100644 --- a/migrations.md +++ b/migrations.md @@ -989,10 +989,13 @@ When modifying a column, you must explicitly include all the modifiers you want $table->integer('votes')->unsigned()->default(1)->comment('my comment')->change(); }); -The `change` method does not change indexes of the column. Therefore, you may use index modifiers explicitly to add/drop an index when modifying the column: +The `change` method does not change the indexes of the column. Therefore, you may use index modifiers to explicitly add or drop an index when modifying the column: ```php +// Add an index... $table->bigIncrements('id')->primary()->change(); + +// Drop an index... $table->char('postal_code', 10)->unique(false)->change(); ``` diff --git a/upgrade.md b/upgrade.md index cf68b5e4f19..1fa7799defa 100644 --- a/upgrade.md +++ b/upgrade.md @@ -101,10 +101,13 @@ Schema::table('users', function (Blueprint $table) { }); ``` -The `change` method does not change indexes of the column. Therefore, you may use index modifiers explicitly to add/drop an index when modifying the column: +The `change` method does not change the indexes of the column. Therefore, you may use index modifiers to explicitly add or drop an index when modifying the column: ```php +// Add an index... $table->bigIncrements('id')->primary()->change(); + +// Drop an index... $table->char('postal_code', 10)->unique(false)->change(); ```