Home php Laravel Migration Error

Laravel Migration Error

Author

Date

Category

Trying to migrate 1 table, but does not give.

Migration code:

& lt;? php
Use Illuminate \ Support \ Facades \ Schema;
Use Illuminate \ Database \ Schema \ Blueprint;
Use ILLUMINATE \ Database \ Migrations \ Migration;
Class CreateUserStable Extends Migration
{
  / **
   * Run The Migrations.
   *
   * @return void
   * /
  Public Function Up ()
  {
    Schema :: Create ('Users', Function (BluePrint $ Table) {
      $ table- & gt; increments ('id');
      $ Table- & gt; String ('Login');
      $ table- & gt; string ('first_name');
      $ Table- & GT; String ('Second_Name');
      $ Table- & gt; String ('patronymic');
      $ table- & gt; String ('Full_name');
      $ Table- & gt; String ('Phone');
      $ Table- & GT; String ('Email');
      $ Table- & GT; Integer ('Group');
      $ table- & gt; string ('password');
      $ Table- & gt; RememberToken ();
      $ Table- & gt; timestamp (); });
  }
  / **
   * Reverse The Migrations.
   *
   * @return void
   * /
  Public Function Down ()
  {
    Schema :: Dropifexists ('Users');
  }
}

gives the following error:

SQLSTATE [42S01]: Base Table or View Already Exists: 1050 Table ‘Roles’ Already Exists

For the sake of interest deleted all the migration files from the folders, the story is repeated. For the first time I see this.


Answer 1, Authority 100%

Dear Adeline is quite simple, I am sure that you have already figured out, but please:
In the error, it is said that one of the tables you are trying to create already have, probably you changed the code of the Schema method :: Create () ‘Role table, with the user table everything is fine. In this case, either re-create all the tables (in developing this common practice) with:

php artisan migrate: refresh // This team will reset and rewrite all migrations

Either just delete the table from the database and start the migration again. I hope that I could help!)) And from me the first like!

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions