Skip to content

Conversation

@Vladelis
Copy link
Contributor

@Vladelis Vladelis commented Jan 6, 2026

Problem

Right now when writing MySQL DDL Operations in migrations it is not possible to define what locking mechanism to use for the statement.

This makes it possible to define what locks to use for altering tables.

Usage example:

    Schema::table('students', function (Blueprint $table) {
        $table->index('email')->lock('none');
    });

As opposed to previously needing something like this

    if (DB::getDriverName() === 'mysql') {
          DB::statement('
              ALTER TABLE `students`
              ADD INDEX `students_email_index` (`email`),
              LOCK = NONE
          ');
    } else {
          Schema::table('students', function (Blueprint $table) {
              $table->index('email');
          });
    }

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@Vladelis Vladelis force-pushed the feature/mysql-ddl-locks branch from fac94df to 6795890 Compare January 6, 2026 14:39
@Vladelis Vladelis marked this pull request as ready for review January 6, 2026 14:47
@AidasK
Copy link

AidasK commented Jan 7, 2026

Would love to have, most of my migrations are using this.

@taylorotwell taylorotwell merged commit 3e11ee3 into laravel:12.x Jan 7, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants