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

Migration: Creating primary key fails with mysql. #49440

Closed
vish404 opened this issue Dec 20, 2023 · 3 comments
Closed

Migration: Creating primary key fails with mysql. #49440

vish404 opened this issue Dec 20, 2023 · 3 comments

Comments

@vish404
Copy link

vish404 commented Dec 20, 2023

Laravel Version

10.38.0

PHP Version

8.1.25

Database Driver & Version

8.0.25 - MySQL Community Server - GPL

Description

Migration fails when trying to add primary keys (on existing table).

Findings

Not working query on v10.38.0

alter table `course_person` drop index if exists `PRIMARY`, add primary key (`course_id`, `person_id`, `role`, `start`)

Working on v10.37.2

alter table `course_person` add primary key (`course_id`, `person_id`, `role`, `start`) 

Steps To Reproduce

Create migration to add primary key to a table.

public function up()
    {
        Schema::table('course_person', function (Blueprint $table) {
            $table->primary(['course_id','person_id','role','start']);
        });
    }
php artisan migrate
@vish404 vish404 changed the title Migration: Creating primary fails in with mysql. Migration: Creating primary key fails in with mysql. Dec 20, 2023
@vish404 vish404 changed the title Migration: Creating primary key fails in with mysql. Migration: Creating primary key fails with mysql. Dec 20, 2023
@aromka
Copy link

aromka commented Dec 20, 2023

Similar issue but when running similar code in older migrations that worked fine before latest update - SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead

@crynobone
Copy link
Member

Hi there,

This seems to have been caused via #49392 and reverted in 10.38.1

@vish404
Copy link
Author

vish404 commented Dec 21, 2023

Hi there,

This seems to have been caused via #49392 and reverted in 10.38.1

Thank you @crynobone

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

No branches or pull requests

3 participants