Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Migration table not created

I am a new learner of Laravel.And I follow the tutorial to create a articles table.Here's part of my code in /database/migrations/2017_02_13_145946_create_article_table.php

public function up()
{
    //
    Schema::create('articles', function(Blueprint $table)
    {
       $table->increments('id');
       $table->string('title');
       $table->text('body')->nullable();
       $table->integer('user_id');
       $table->timestamps();
    });
}

When I run php artisan migrate the table was not created.I googled the problem and ran php artisan migrate:reset command to delete all the tables.When I ran php artisan migate command again.It shows

Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrated: 2017_02_13_145946_create_article_table

But nothing was created but only updated the record of migrations table.The table user and password_resets was also not created.

Any ideas what I might be doing wrong?

like image 414
Shawn Rong Avatar asked Mar 10 '23 21:03

Shawn Rong


1 Answers

It is because of Table column(values) length is by default 1071 which not accept by mysql

To clear this problem go to mysql and delete all the tables. Go to your application(project) folder => app => Providers

write this on top of your AppServiceProvider.php file.

//edit:yrs:- Needed for edit
use Illuminate\Support\Facades\Schema;

write this inside the boot method

//edit:yrs:-we can edit column sizefor tables here
Schema::defaultStringLength(150);

then come to console and execute the


*command />php artisan migrate:status and see the run status is y or n if it is n then execute

*command />`php artisan migrate`

*command />`php artisan migrate:status` and then 

*command />`php artisan migrate:refresh` and then 

*command />`php artisan migrate:status`

that's all your done with createing with tables in mysql

like image 89
Rajasekhar Avatar answered Mar 21 '23 10:03

Rajasekhar