hootlex / laravel-friendships

This package gives Eloquent models the ability to manage their friendships.
MIT License
706 stars 151 forks source link

"Incorrect table name" after publishing the vendor #122

Closed Baspa closed 5 years ago

Baspa commented 5 years ago

I followed these steps:

When I try to migrate the database I get the following error:

Migrating: 2019_02_10_125533_create_friendships_table

Illuminate\Database\QueryException  : SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (`id` int unsigned not null auto_increment primary key, `sender_type` varchar(191) not null, `sender_id` bigint unsign
ed not null, `recipient_type` varchar(191) not null, `recipient_id` bigint unsigned not null, `status` tinyint not null default '0', `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

Maybe I did something wrong by not following this step:

Configure the published config in
config\friendships.php

But I don't know what is meant with configure the published config? What do I have to config here? I didn't create the migrations myself like this person did here: https://github.com/hootlex/laravel-friendships/issues/94

TechTailor commented 5 years ago

If you have published the config files using :

php artisan vendor:publish --provider="Hootlex\Friendships\FriendshipsServiceProvider"

Go to config/friendships.php and see if it matches this -

<?php
return [
    'tables' => [
        'fr_pivot' => 'friendships',
        'fr_groups_pivot' => 'user_friendship_groups'
    ],
    'groups' => [
        'acquaintances' => 0,
        'close_friends' => 1,
        'family' => 2
    ]
];

If its the same then clear your config & compiled files by running php artisan config:clear and php artisan clear-compiled in your console and then run your migration again.

If it still doesn't work, go to bootrap/cache/ folder and delete all files inside that folder, restart the server and try again.

-TT

Baspa commented 5 years ago

Running config:clear and clear-compiled worked. Thanks for you fast reply.