Modifiying existing table with Laravel migrations error

Posted 2 years ago by keevitaja

Hello!

I took over a project and i need to modify a table. Add some columns. I created this migration:

    public function up()
    {
        Schema::table('contact_details', function ($table) {
            $table->string('uid');
            $table->string('university')->nullable();
            $table->string('graduation')->nullable();
            $table->string('qualification')->nullable();
            $table->integer('voucher_1')->nullable();
            $table->integer('voucher_2')->nullable();
            $table->boolean('voucher_1_confirmed')->nullable();
            $table->boolean('voucher_2_confirmed')->nullable();
            $table->string('home_address')->nullable();
            $table->string('home_phone')->nullable();
            $table->string('company_name')->nullable();
            $table->string('company_position')->nullable();
            $table->string('company_address')->nullable();
            $table->string('company_phone')->nullable();
            $table->string('company_gsm')->nullable();
            $table->string('company_email')->nullable();
            $table->string('company_sphere')->nullable();
            $table->string('company_speciality')->nullable();
        });
    }

But when i run php artisan migrate, i get the following error:

  [Illuminate\Database\QueryException]                                                                                           
  SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'checked_out_time'   
  at row 1 (SQL: alter table `zu7gm_contact_details` add `uid` varchar(255) not null, add `university` varchar(255) null, add `  
  graduation` varchar(255) null, add `qualification` varchar(255) null, add `voucher_1` int null, add `voucher_2` int null, add  
   `voucher_1_confirmed` tinyint(1) null, add `voucher_2_confirmed` tinyint(1) null, add `home_address` varchar(255) null, add   
  `home_phone` varchar(255) null, add `company_name` varchar(255) null, add `company_position` varchar(255) null, add `company_  
  address` varchar(255) null, add `company_phone` varchar(255) null, add `company_gsm` varchar(255) null, add `company_email` v  
  archar(255) null, add `company_sphere` varchar(255) null, add `company_speciality` varchar(255) null)                          
                                                                                                                                 

                                                                                                                                 
  [PDOException]                                                                                                                 
  SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'checked_out_time'   
  at row 1                                                                                                                       

What may be causing this? The column in error is present and is datatime.

Edit: And i can add fields with just mysql -u user -p table < some.sql

Please sign in or create an account to participate in this conversation.