0

I followed everything in http://four.laravel.com/docs/eloquent#many-to-many and I found the same problem in How is a pivot table created by laravel after applying the solution I got the migration file and I've made my changes

public function up()
    {
        Schema::table('Card_User', function (Blueprint $table) {
          $table->increments('id');
          $table->integer('Card_id');
          $table->integer('User_id');
          $table->integer('additional_var');
        });
    }

But when I try to php artisan migrate:refresh I always get

[Illuminate\Database\QueryException]                                            
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.Card_User' d  
  oesn't exist (SQL: alter table `Card_User` add `id` int unsigned not null auto  
  _increment primary key, add `Card_id` int not null, add `User_id` int not null  
  , add `additional_var` int not null)                                    



  [PDOException]                                                                  
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'waawia.Card_User' d  
  oesn't exist   

After folowwing some other webpages i tried to :

  • php artisan migrate:install

  • Delete all the database tables manually and refresh the migration

  • Restarted php artisan serve and now it's closed

  • Some other things ...

But still have the same problem

Community
  • 1
  • 1
Khalil Bz
  • 557
  • 1
  • 9
  • 24

1 Answers1

1

if you are creating a table, change

Schema::table('Card_User', function (Blueprint $table) {}

to

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

Schema::table() is used to alter an existing table while Schema::create() does what it implies.

Andrew Nolan
  • 1,987
  • 2
  • 20
  • 23
  • Thank you :') So much , I worked a lot and I didn't find it until now , I will choose your answer as the best one , just a minute ^_^ ありがとうぐざいます – Khalil Bz Jul 17 '16 at 18:01