Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add upgrade note for changed migration behaviour #9989

Draft
wants to merge 1 commit into
base: 11.x
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<div class="content-list" markdown="1">

- [Doctrine DBAL Removal](#doctrine-dbal-removal)
- [Renaming And Adding Columns](#renaming-and-adding-columns)
- [Eloquent Model `casts` Method](#eloquent-model-casts-method)
- [Spatial Types](#spatial-types)
- [The `Enumerable` Contract](#the-enumerable-contract)
Expand Down Expand Up @@ -277,6 +278,31 @@ php artisan schema:dump

Once your migrations have been squashed, Laravel will "migrate" the database using your application's schema file before running any pending migrations.

<a name="renaming-and-adding-columns"></a>
#### Renaming And Adding Columns

**Likelihood Of Impact: Low**

When renaming a column and adding a new column after the renamed column, using the `after()` modifier, changes are required because the order of operations performed by `Schema::table()` has changed.

For example, imagine you have a migration that renames a `votes` column, and then adds a `description` column:

```php
Schema::table('users', function (Blueprint $table) {
$table->string('description')->after('votes');
$table->renameColumn('votes', 'vote_count');
});
```

In Laravel 10, this works as expected. However, in Laravel 11, this causes an error because the renaming operation occurs first. Instead, the `after()` modifier must now refer to the new column name:

```php
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('votes', 'vote_count');
$table->string('description')->after('vote_count');
});
```

<a name="floating-point-types"></a>
#### Floating-Point Types

Expand Down