vendredi 3 mai 2019

laravel 5.8 Schema add foreign key not working

I'm trying to create foreign keys in Laravel 5.8 however when I migrate my table using artisan foreign key not set!

 public function up()
{
    Schema::table('users', function (Blueprint $table) {

        $table->integer('city_id')->unsigned();
        $table->integer('province_id')->unsigned();
        // table Foreign Key
        $table->foreign('city_id')->references('id')->on('cities');
        $table->foreign('province_id')->references('id')->on('provinces');
    });
}

in cities table and provinces table all id fields is unsigned integer. im working with wamp64 on window 10



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Jee5Ik
via IFTTT

Aucun commentaire:

Enregistrer un commentaire