3

I created a migration with post_id unsigned. How can I edit post_id in a new migration to also make it nullable()?

    Schema::create('throttle', function(Blueprint $table)
    {
        $table->increments('id');
        $table->integer('post_id')->unsigned(); // this needs to also be nullable, how should the next migration be?
    }
EstevaoLuis
  • 2,422
  • 7
  • 33
  • 40
Fayyaz Ahmed
  • 31
  • 1
  • 6
  • Does this answer your question? [Laravel Migration Change to Make a Column Nullable](https://stackoverflow.com/questions/24419999/laravel-migration-change-to-make-a-column-nullable) – miken32 Nov 19 '20 at 04:42

2 Answers2

9

Create migrate and add in your up function like this:

$table->integer('post_id')->nullable()->change();
Truong Dang
  • 3,119
  • 1
  • 15
  • 21
-4
 php artisan migrate:rollback

change your migration

$table->integer('post_id')->nullable();

then

php artisan migrate
Kuldeep Mishra
  • 3,846
  • 1
  • 21
  • 26