0

I have read many post on this subject, but have not found the right answer. When i write any command php artisan migrate returns a result:

[Illuminate\Database\QueryException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'adtmart1.shop_categories' doesn't exist (SQL: select * f
  rom `shop_categories`)


[PDOException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'adtmart1.shop_categories' doesn't exist

I would like to move the finished website made using Laravel on the local web server. I use Web server - opensever. There php version - 5.5, Mysql - 5.5. All commands i write of the console opensever. While replying, please, take into consideration that I am new in this field

Saahon
  • 404
  • 1
  • 6
  • 27

2 Answers2

1

You use Schema::table to alter an existing table, you are looking for Schema::create which is used to create a new table.

Alter your migrations to use Schema::create and you'll have no trouble running your migrations:

Schema::create('name_of_table', function(Blueprint $table) {
        {

            $table->increments("id",true);
            $table->string("username")->nullable()->default(null);
            $table->string("password")->nullable()->default(null);
            $table->string("email")->nullable()->default(null);
            $table->timestamps();
        });

I have of course used dummy columns and you would use your own.

More info on the problem here.

Community
  • 1
  • 1
James
  • 15,754
  • 12
  • 73
  • 91
0

First of all, you'll need to post migration code that causes the error. To do this, try to run migrations one-by-one. Remove all migrations from /database/migrations folder and then add first one (first by date it was created) back into /database/migrations. Then run php artisan migrate. If migrations was successful, do all steps for secons migration etc. When you see an error, you'll know that this one migrations causes it. Post it here please, so we could help.

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
  • First remove all files from the folder database/migrations. Then, through the openserver console write command: php artisan migrate:make create_users_table. because in the folder database/migrations by date the very first file was 2014_10_12_000000_create_users_table.php – Saahon Mar 03 '16 at 10:09
  • You do not need to create new migrations with `migrate:make`, you already have all migrations. Just add them one-by-one back to `/database/migrations` folder and run `php artisan migrate` command after each added migration. – Alexey Mezenin Mar 03 '16 at 10:12
  • still returns an error from the first file: " [Illuminate\Database\QueryException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'adtmart1.shop_categories' doesn't exist (SQL: select * f rom `shop_categories`)" – Saahon Mar 03 '16 at 10:16
  • Of course it should cause an error. The important this is after what exactly migration? You need to find the problematic migration and post it here. – Alexey Mezenin Mar 03 '16 at 10:19
  • after the error I deleted first file and copied the second file and re write command "php artisan migrate", after this command also error – Saahon Mar 03 '16 at 10:24