Laravel - Seed Migration Failed - Mysharetechno

Mysharetechno

Blog ini berisi tentang review gadget, Tutorial, Games, Coding serta hal menarik lainya seputar Teknologi terbaru seputar Gadget

Post Top Ad

Laravel - Seed Migration Failed

Laravel - Seed Migration Failed

Share This

 

Laravel - Seed Migration Failed

Detail Error : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`)) 


How to Fix it: 

  1. Go to the root folder \APP\Providers\AppServiceProvider.php
  2. Add Script
    use Illuminate\Support\Facades\Schema;
    and Schema::defaultStringLength(191);
    (SQL: alter table `users` add unique `users_email_unique`(`email`))


  3. Save and  don’t forget to remove table data on database


  4. Another mistake like this will show if you forget to delete a database table.
    “SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table `users` (`id` int unsigned not null auto_increment primary key, `name` varchar(191) not null, `email` varchar(191) not null, `email_verified_at` timestamp null, `password` varchar(191) not null, `photo` varchar(191) null, `gender` varchar(191) not null, `active` int not null, `deleted_at` timestamp null, `remember_token` varchar(100) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')”



  5. And you can run again to migrate data “php artisan migrate –seed”


Tidak ada komentar:

Posting Komentar

Post Bottom Ad