-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Closed
Labels
Description
- Laravel Version: 6.5
- PHP Version: 7.3.11
- Database Driver & Version: MySQL - 5.7.27-0ubuntu0.18.04.1
Description:
While writing a migration to fix a bad database that had stored a foreign key as a varchar, I wrote the following migration:
Schema::table('jobseeker_qualifications', function (Blueprint $table) {
$table->bigIncrements('id')->change();
$table->unsignedBigInteger('user_id')->change();
$table->unsignedBigInteger('jobseekers_education_id')->change();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('jobseekers_education_id')->references('id')->on('jobseeker_educations');
});
However, this above migration generated the following SQL:
ALTER TABLE jobseeker_qualifications
CHANGE id id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
CHANGE jobseekers_education_id jobseekers_education_id BIGINT UNSIGNED CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci`,
CHANGE user_id user_id BIGINT UNSIGNED NOT NULL
Work Around: Removing the instructions related to the character set and running this query manually was successful.
Steps To Reproduce:
- Create a table containing a VARCHAR field that contains valid id values (only numbers).
- Run a migration similar to the above, requesting a change the VARCHAR to unsigned BIGINT.
ryancwalsh, elijahchancey, Niksac and pelletiermaxime