Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save diegoglz-dev/9d1d29070daa130f02fa7fad65f0282b to your computer and use it in GitHub Desktop.

Select an option

Save diegoglz-dev/9d1d29070daa130f02fa7fad65f0282b to your computer and use it in GitHub Desktop.
Change nullable foreign key on production.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('items', function (Blueprint $table) {
$table->unsignedBigInteger('product_id')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('items', function (Blueprint $table) {
$table->unsignedBigInteger('product_id')->change();
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment