PikoPong
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux
No Result
View All Result
PikoPong
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux
No Result
View All Result
PikoPong
No Result
View All Result
Home Web Dev

Add Multiple Columns After a Column in Migrations

February 19, 2021
in Web Dev
289 3
Add Multiple Columns After a Column in Migrations


Laravel 8.27 introduces a new after method on the Blueprint migration instance which allows you to add multiple new columns after an existing column at the same time:

Coming to Laravel next week: Add multiple columns after a specific column. pic.twitter.com/WzfW9mWCcY

— Mohamed Said (@themsaid) February 5, 2021

Previously, you’d have to reference each new column to get the order correct—you can see that the after cleans up this code nicely:

Schema::table('customers', function ($table) {
    $table->string('address_line1')->after('password');
    $table->string('address_line2')->after('address_line1');
    $table->string('city')->after('address_line2');
});

While the original code isn’t difficult to write, the after() method avoids repetitive after() calls for each subsequent new column and gives a nice abstraction for adding multiple columns. Pairing this with Laravel 8 migration squashing and model factory classes, Laravel continues to improve what is already some of the best migration tools available in any framework.

If you’d like to learn more about how Laravel implemented this feature, check out Pull Request #36145. Adding multiple columns after an existing column is available with the release of v8.27.0.





Source link

Share219Tweet137Share55Pin49

Related Posts

Web Components Are Easier Than You Think
Web Dev

Web Components Are Easier Than You Think

When I’d go to a conference (when we were able to do such things) and see someone do a...

March 8, 2021
Going Beyond The Basics — Smashing Magazine
Web Dev

Obscure Mobile Design Techniques That Boost UX — Smashing Magazine

About The AuthorGert Svaiko is a professional copywriter and mainly works with digital marketing companies in the US and...

March 8, 2021
Invoker–the no-bull Laravel tool | Laravel News
Web Dev

Invoker–the no-bull Laravel tool | Laravel News

Invoker by Beyond Code lets you access all your Laravel applications with an instant admin panel—locally, via SSH and...

March 8, 2021
Laravel Tutorial: Step by Step Guide to Building Your First Laravel Application
Web Dev

Laravel Tutorial: Step by Step Guide to Building Your First Laravel Application

Since its initial release in 2011, Laravel has experienced exponential growth. In 2015, it became the most starred PHP...

March 7, 2021
Next Post

Clipping Scrollable Areas On The inline-start Side

Announcing Laracon Online 2021 | Laravel News

Announcing Laracon Online 2021 | Laravel News

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

Jetpack CRM | CSS-Tricks

Jetpack CRM | CSS-Tricks

August 4, 2020
How to Install Itch on Ubuntu and Other Linux Distributions

How to Install Itch on Ubuntu and Other Linux Distributions

August 4, 2020
Responsible Web Applications

Responsible Web Applications

February 12, 2021
Accessibility In Chrome DevTools — Smashing Magazine

Accessibility In Chrome DevTools — Smashing Magazine

September 1, 2020

Categories

  • AWS
  • Big Data
  • Database
  • DevOps
  • IoT
  • Linux
  • Web Dev
No Result
View All Result
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In