I would use the same structure in the new database then alter it or alter the old one first then export. Doing it on the fly is not the first option I'd choose.
General error: 1366 Incorrect integer value: '' for column
Hi.
Im transferring a database over so i can set it up with relationships etc on laravel and im coming across the error General error: 1366 Incorrect integer value: '' for column 'name1_verified' at row 1
I know its due to trying to save from a string to a bool but how can i make change it from string to boolean.
As it is now i have a name1_verified on both databases but it only has either 1 or 0 in on the old db. I want it to be a boolean on the new db, so in the migrations ive set it to boolean.
If i change the type in the new db to string then it just doesn't save it at all!
Console/MigrateAll.php
public function handle(){
$users = User::all();
$bar = $this->output->createProgressBar(count($users));
$this->line("\nMigrating Verified Users::");
foreach ($users as $user) {
$old_user = OldUsers::where('mailbox_id', $user->mailbox_id)->first();
$old_mailbox = OldMailbox::where('mailbox_id', $user->mailbox_id)->first();
$customer = VerifiedUser::where('user_id', $user->id)->first();
if(!$customer){
User::where('mailbox_id', $user->mailbox_id)->update(['name' => $old_mailbox['name1']]);
$verified_user = new VerifiedUser();
$verified_user->user_id = $user['id'];
$verified_user->name1 = $old_mailbox['name1'];
$verified_user->name1_verified = $old_mailbox['name1_verified'];
$verified_user->name1_verified = $old_mailbox['name1_verified_date'];
$verified_user->name2 = $old_mailbox['name2'];
$verified_user->name2_verified = $old_mailbox['name2_verified'];
$verified_user->name2_verified = $old_mailbox['name2_verified_date'];
$verified_user->name3 = $old_mailbox['name3'];
$verified_user->name3_verified = $old_mailbox['name3_verified'];
$verified_user->name3_verified = $old_mailbox['name3_verified_date'];
$verified_user->name4 = $old_mailbox['name4'];
$verified_user->name4_verified = $old_mailbox['name4_verified'];
$verified_user->name4_verified = $old_mailbox['name4_verified_date'];
$verified_user->name5 = $old_mailbox['name5'];
$verified_user->name5_verified = $old_mailbox['name5_verified'];
$verified_user->name5_verified = $old_mailbox['name5_verified_date'];
$verified_user->verified_postcode = $old_mailbox['verified_postcode'];
$verified_user->save();
$bar->advance();
}
};
$bar->finish();
$this->info(" Complete... \n");
}
$verified_user->name1_verified = $old_mailbox['name1_verified']; $verified_user->name1_verified = $old_mailbox['name1_verified_date'];
Why are you setting the same property twice?
Please or to participate in this conversation.