2018_04_19_095256_create_admins_table.php
, This is the name that
generate when i run the command "php artisan make:migration... "
It does not show on my data base when i run the command "php artisan migrate" .
But when i change the name of the migration it runs. I change the
migration name of "2018_04_19_095256_create_admins_table.php"
to
"2014_04_19_095256_create_admins_table.php"
.
Also "2014_10_12_100000_create_password_resets_table.php"
didn't show on my database
Is there any way that i can use the generate name for my migration?
Migration file code:
Migration table created successfully.
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `admins` add unique `admins_email_unique`(`email`))
at C:\xampp\htdocs\century\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
C:\xampp\htdocs\century\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
2 PDOStatement::execute()
C:\xampp\htdocs\century\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
Please use the argument -v to see more details.
Go into your AppServiceProvider which will be located at App/Providers and edit it as follow
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
}
Note We added the use for Schema and added the Schema::defaultStringLength in the boot function. This will remove the error.