Laravel 5.2 how to update migration without losing data

前端 未结 4 1613
天涯浪人
天涯浪人 2021-01-30 13:27

I\'m using laravel 5.2 and I usually update my database according to project requirements, so I\'d like to do it without losing database records. I don\'t mean how to seed my da

4条回答
  •  一生所求
    2021-01-30 14:01

    Make a new migration with

    php artisan make:migration change_body_to_nullable_in_reviews_table --table=reviews
    

    where you put this

        public function up()
        {
            Schema::table('reviews', function (Blueprint $table) {
                $table->text('body')->nullable()->change();
            });
        }
    
        public function down()
        {
            Schema::table('reviews', function (Blueprint $table) {
                $table->text('body')->nullable(false)->change();
            });
        }
    

    And then run PHP artisan migrate

提交回复
热议问题