i'm trying to add a foreign ID column to an existing table. I've done so successfully and all my PHPunit tests pass locally:
Schema::table('responses', function (Blueprint $table) {
$table->foreignId('road_id')
->after('id')
->nullable()
->constrained();
$table->string('email')->after('road_id');
});
I have github actions setup and all the PHPunit tests seem to fail with the Error (both running sqlite):
Cannot add a NOT NULL column with default value NULL (SQL: alter table "responses" add
column "email" varchar not null)
Im having a hard time debugging this error since everything works locally. Any issues with the approach I took?
EDIT: I've updated my question since i'm now seeing a different error message through my github action. It is in relation to adding an email column to an already existing table. Any reason why this wouldn't be allowed? My current work around was change the email column creation to:
$table->string('email')->nullable()->after('road_id');
And then i created an additional migration that does this:
$table->string('email')->nullable(false)->change();
Now both tests are passing both locally and in my github action. I'm still very unsure as to the big question... why did I have to create that additional migration just to change the column to not nullable in order for my github action to run tests successfully? Any insight is much appreciated.